Commit ca81bcff authored by Camil Staps's avatar Camil Staps 🍃

Update submodule; overwrite rank settings CAF on start-up

parent 5be52411
Pipeline #16836 passed with stage
in 15 minutes and 17 seconds
Subproject commit 7563b05f00f7403ef72ab9425dd5f1e3fba7657f
Subproject commit 299aef08632887d4b013969b97f9fb65e9aab8e2
......@@ -187,13 +187,15 @@ Start w
# rsets = fromJSON $ fromString $ fromOk f
| isError f || isNothing rsets = errexit "Could not open rank settings\n" -1 w
#! rsets = fromJust rsets
#! (ok,rsets) = setRankSettings rsets
| not ok = errexit "Failed to set rank settings\n" -1 w
| isJust opts.test_file
# (ok,f,w) = fopen (fromJust opts.test_file) FReadText w
| not ok = errexit "Could not open test file\n" -1 w
= test opts.test_options rsets f db w
#! (db,w) = if opts.reload_cache (doInBackground (reloadCache rsets)) id (db,w)
= test opts.test_options f db w
#! (db,w) = if opts.reload_cache (doInBackground reloadCache) id (db,w)
= serve
{ handler = handle rsets
{ handler = handle
, logger = Just log
, port = opts.Options.port
, connect_timeout = Just 3600000 // 1h
......@@ -212,9 +214,9 @@ errexit msg rcode w
# (_,w) = fclose (stderr <<< msg) w
= setReturnCode rcode w
handle :: !RankSettings !(Maybe Request) !*CloogleDB !*World -> *(!Response, !(!Maybe CacheKey, !MicroSeconds), !*CloogleDB, !*World)
handle _ Nothing db w = (err InvalidInput "Couldn't parse input" Nothing, (Nothing,0), db, w)
handle rsets (Just request=:{unify,name,page}) db w
handle :: !(Maybe Request) !*CloogleDB !*World -> *(!Response, !(!Maybe CacheKey, !MicroSeconds), !*CloogleDB, !*World)
handle Nothing db w = (err InvalidInput "Couldn't parse input" Nothing, (Nothing,0), db, w)
handle (Just request=:{unify,name,page}) db w
#! (start,w) = nsTime w
//Check cache
#! (key,db) = toRequestCacheKey db request
......@@ -232,7 +234,7 @@ handle rsets (Just request=:{unify,name,page}) db w
= respond start Nothing (err InvalidInput "Empty query" Nothing) db w
// Results
#! drop_n = fromJust (page <|> pure 0) * MAX_RESULTS
#! (res,suggs,db) = searchWithSuggestions rsets request db
#! (res,suggs,db) = searchWithSuggestions request db
#! suggs = if (isEmpty suggs) Nothing (Just suggs)
#! results = drop drop_n res
#! more = max 0 (length results - MAX_RESULTS)
......@@ -281,8 +283,8 @@ where
}
(give,keep) = splitAt MAX_RESULTS results
reloadCache :: !RankSettings !*(!*CloogleDB, !*World) -> *(!*CloogleDB, !*World)
reloadCache rsets (db,w)
reloadCache :: !*(!*CloogleDB, !*World) -> *(!*CloogleDB, !*World)
reloadCache (db,w)
# (ks,w) = allCacheKeys LongTerm w
= loop ks db w
where
......@@ -290,7 +292,7 @@ where
loop [] db w = (db,w)
loop [k:ks] db w
# w = removeFromCache LongTerm k w
# (_,_,db,w) = handle rsets (Just $ fromRequestCacheKey k) db w
# (_,_,db,w) = handle (Just $ fromRequestCacheKey k) db w
# db = resetDB db
= loop ks db w
......@@ -301,8 +303,8 @@ doInBackground f w
| pid > 0 = w // Parent: return directly
| otherwise = snd $ exit 0 $ f w // Child: do function
test :: ![TestOption] !RankSettings !*File !*CloogleDB !*World -> *World
test opts rsets queries db w
test :: ![TestOption] !*File !*CloogleDB !*World -> *World
test opts queries db w
# (e,queries) = fend queries
| e = w
# (qstring,queries) = freadline queries
......@@ -310,12 +312,12 @@ test opts rsets queries db w
# q = parseSingleLineRequest qstring
| isError q
# w = snd $ fclose (stderr <<< "Warning: could not parse '" <<< qstring <<< "'; " <<< fromError q <<< "\n") w
= test opts rsets queries db w
= test opts queries db w
# q = fromOk q
| excluded opts q
= test opts rsets queries db w
# (_,_,db,w) = handle rsets (Just q) db w
= test opts rsets queries db w
= test opts queries db w
# (_,_,db,w) = handle (Just q) db w
= test opts queries db w
where
excluded :: ![TestOption] !Request -> Bool
excluded [] _ = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment