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 ...@@ -187,13 +187,15 @@ Start w
# rsets = fromJSON $ fromString $ fromOk f # rsets = fromJSON $ fromString $ fromOk f
| isError f || isNothing rsets = errexit "Could not open rank settings\n" -1 w | isError f || isNothing rsets = errexit "Could not open rank settings\n" -1 w
#! rsets = fromJust rsets #! rsets = fromJust rsets
#! (ok,rsets) = setRankSettings rsets
| not ok = errexit "Failed to set rank settings\n" -1 w
| isJust opts.test_file | isJust opts.test_file
# (ok,f,w) = fopen (fromJust opts.test_file) FReadText w # (ok,f,w) = fopen (fromJust opts.test_file) FReadText w
| not ok = errexit "Could not open test file\n" -1 w | not ok = errexit "Could not open test file\n" -1 w
= test opts.test_options rsets f db w = test opts.test_options f db w
#! (db,w) = if opts.reload_cache (doInBackground (reloadCache rsets)) id (db,w) #! (db,w) = if opts.reload_cache (doInBackground reloadCache) id (db,w)
= serve = serve
{ handler = handle rsets { handler = handle
, logger = Just log , logger = Just log
, port = opts.Options.port , port = opts.Options.port
, connect_timeout = Just 3600000 // 1h , connect_timeout = Just 3600000 // 1h
...@@ -212,9 +214,9 @@ errexit msg rcode w ...@@ -212,9 +214,9 @@ errexit msg rcode w
# (_,w) = fclose (stderr <<< msg) w # (_,w) = fclose (stderr <<< msg) w
= setReturnCode rcode w = setReturnCode rcode w
handle :: !RankSettings !(Maybe Request) !*CloogleDB !*World -> *(!Response, !(!Maybe CacheKey, !MicroSeconds), !*CloogleDB, !*World) 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 Nothing db w = (err InvalidInput "Couldn't parse input" Nothing, (Nothing,0), db, w)
handle rsets (Just request=:{unify,name,page}) db w handle (Just request=:{unify,name,page}) db w
#! (start,w) = nsTime w #! (start,w) = nsTime w
//Check cache //Check cache
#! (key,db) = toRequestCacheKey db request #! (key,db) = toRequestCacheKey db request
...@@ -232,7 +234,7 @@ handle rsets (Just request=:{unify,name,page}) db w ...@@ -232,7 +234,7 @@ handle rsets (Just request=:{unify,name,page}) db w
= respond start Nothing (err InvalidInput "Empty query" Nothing) db w = respond start Nothing (err InvalidInput "Empty query" Nothing) db w
// Results // Results
#! drop_n = fromJust (page <|> pure 0) * MAX_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) #! suggs = if (isEmpty suggs) Nothing (Just suggs)
#! results = drop drop_n res #! results = drop drop_n res
#! more = max 0 (length results - MAX_RESULTS) #! more = max 0 (length results - MAX_RESULTS)
...@@ -281,8 +283,8 @@ where ...@@ -281,8 +283,8 @@ where
} }
(give,keep) = splitAt MAX_RESULTS results (give,keep) = splitAt MAX_RESULTS results
reloadCache :: !RankSettings !*(!*CloogleDB, !*World) -> *(!*CloogleDB, !*World) reloadCache :: !*(!*CloogleDB, !*World) -> *(!*CloogleDB, !*World)
reloadCache rsets (db,w) reloadCache (db,w)
# (ks,w) = allCacheKeys LongTerm w # (ks,w) = allCacheKeys LongTerm w
= loop ks db w = loop ks db w
where where
...@@ -290,7 +292,7 @@ where ...@@ -290,7 +292,7 @@ where
loop [] db w = (db,w) loop [] db w = (db,w)
loop [k:ks] db w loop [k:ks] db w
# w = removeFromCache LongTerm k 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 # db = resetDB db
= loop ks db w = loop ks db w
...@@ -301,8 +303,8 @@ doInBackground f w ...@@ -301,8 +303,8 @@ doInBackground f w
| pid > 0 = w // Parent: return directly | pid > 0 = w // Parent: return directly
| otherwise = snd $ exit 0 $ f w // Child: do function | otherwise = snd $ exit 0 $ f w // Child: do function
test :: ![TestOption] !RankSettings !*File !*CloogleDB !*World -> *World test :: ![TestOption] !*File !*CloogleDB !*World -> *World
test opts rsets queries db w test opts queries db w
# (e,queries) = fend queries # (e,queries) = fend queries
| e = w | e = w
# (qstring,queries) = freadline queries # (qstring,queries) = freadline queries
...@@ -310,12 +312,12 @@ test opts rsets queries db w ...@@ -310,12 +312,12 @@ test opts rsets queries db w
# q = parseSingleLineRequest qstring # q = parseSingleLineRequest qstring
| isError q | isError q
# w = snd $ fclose (stderr <<< "Warning: could not parse '" <<< qstring <<< "'; " <<< fromError q <<< "\n") w # 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 # q = fromOk q
| excluded opts q | excluded opts q
= test opts rsets queries db w = test opts queries db w
# (_,_,db,w) = handle rsets (Just q) db w # (_,_,db,w) = handle (Just q) db w
= test opts rsets queries db w = test opts queries db w
where where
excluded :: ![TestOption] !Request -> Bool excluded :: ![TestOption] !Request -> Bool
excluded [] _ = False 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