Skip to content

Commit 9795d27

Browse files
authored
Update API.hs - preventing caching of empty result set
Signed-off-by: bosko-m <[email protected]>
1 parent f23389d commit 9795d27

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

govtool/backend/src/VVA/API.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,11 @@ listProposals selectedTypes sortMode mPage mPageSize mDrepRaw mSearchQuery = do
407407

408408
CacheEnv {proposalListCache} <- asks vvaCache
409409

410-
proposals <- cacheRequest proposalListCache () (Proposal.listProposals mSearchQuery)
410+
proposals <- do
411+
result <- Proposal.listProposals mSearchQuery
412+
if null result
413+
then return result
414+
else cacheRequest proposalListCache cacheKey (pure result)
411415

412416
mappedSortedAndFilteredProposals <- mapSortAndFilterProposals selectedTypes sortMode proposals
413417
let filteredProposals = filter

0 commit comments

Comments
 (0)