Fix issue #6
Avoid generating a large SQL query by making the patterns an ad-hoc table
This commit is contained in:
parent
217530d113
commit
343136536f
14
Main.hs
14
Main.hs
@ -146,11 +146,17 @@ deleteQuotaOrigins = do
|
|||||||
n <- S.deleteFrom quotaOrigins (by whitelist)
|
n <- S.deleteFrom quotaOrigins (by whitelist)
|
||||||
return (n, nub bad)
|
return (n, nub bad)
|
||||||
where
|
where
|
||||||
-- check if x ∉ set
|
-- check if quota is not whitelisted
|
||||||
by set x = S.not_ . any_ . map (S.like (x ! #origin)) $ set
|
by whitelist quota = S.not_ (S.true `S.isIn` matches)
|
||||||
|
where
|
||||||
|
url = quota ! #origin
|
||||||
|
matches = do
|
||||||
|
pattern <- S.selectValues (map S.Only whitelist)
|
||||||
|
S.restrict (url `S.like` S.the pattern)
|
||||||
|
return S.true
|
||||||
-- turns domains into patterns to match a url
|
-- turns domains into patterns to match a url
|
||||||
pattern domain = S.text ("http%://%" <> domain <> "/")
|
pattern domain = "http%://%" <> domain <> "/"
|
||||||
any_ = foldl' (.||) S.false
|
|
||||||
|
|
||||||
|
|
||||||
-- | Deletes per-domain files under the IndexedDB directory
|
-- | Deletes per-domain files under the IndexedDB directory
|
||||||
|
Loading…
Reference in New Issue
Block a user