mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
03377da1b5
commit
08c61d9000
|
@ -365,11 +365,10 @@ refchanExport dry = do
|
||||||
-- только такие элементы, которые реально отсутствуют
|
-- только такие элементы, которые реально отсутствуют
|
||||||
-- в рефчане
|
-- в рефчане
|
||||||
what <- select_ @_ @FixmeExported [qc|
|
what <- select_ @_ @FixmeExported [qc|
|
||||||
select distinct o,0,k,cast (v as text)
|
select distinct o,w,k,cast (v as text)
|
||||||
from object obj
|
from object obj
|
||||||
where not exists (select null from scanned where hash = obj.nonce)
|
where not exists (select null from scanned where hash = obj.nonce)
|
||||||
or obj.nonce is null
|
order by o, k, v, w
|
||||||
order by o, k, v
|
|
||||||
|]
|
|]
|
||||||
|
|
||||||
let chu = chunksOf 10000 what
|
let chu = chunksOf 10000 what
|
||||||
|
@ -415,9 +414,11 @@ refchanImport = do
|
||||||
|
|
||||||
-- TODO: assume-huge-list
|
-- TODO: assume-huge-list
|
||||||
-- scanned <- listAllScanned
|
-- scanned <- listAllScanned
|
||||||
let isScanned = selectIsAlreadyScanned
|
let goodToGo x = do
|
||||||
|
here <- selectIsAlreadyScanned x
|
||||||
|
pure $ not here
|
||||||
|
|
||||||
walkRefChanTx @UNIX isScanned chan $ \txh u -> do
|
walkRefChanTx @UNIX goodToGo chan $ \txh u -> do
|
||||||
|
|
||||||
case u of
|
case u of
|
||||||
|
|
||||||
|
@ -436,6 +437,8 @@ refchanImport = do
|
||||||
|
|
||||||
scanned <- lift $ selectIsAlreadyScanned href
|
scanned <- lift $ selectIsAlreadyScanned href
|
||||||
|
|
||||||
|
-- notice $ yellow "SCANNED" <+> pretty scanned
|
||||||
|
|
||||||
if scanned then do
|
if scanned then do
|
||||||
atx <- readTVarIO accepts <&> fromMaybe mempty . HM.lookup txh
|
atx <- readTVarIO accepts <&> fromMaybe mempty . HM.lookup txh
|
||||||
lift $ withState $ transactional do
|
lift $ withState $ transactional do
|
||||||
|
@ -453,7 +456,6 @@ refchanImport = do
|
||||||
& toMPlus
|
& toMPlus
|
||||||
|
|
||||||
for_ exported $ \exported -> do
|
for_ exported $ \exported -> do
|
||||||
unless scanned do
|
|
||||||
atomically $ writeTQueue tq (txh, orig, href, exported)
|
atomically $ writeTQueue tq (txh, orig, href, exported)
|
||||||
|
|
||||||
imported <- atomically $ flushTQueue tq
|
imported <- atomically $ flushTQueue tq
|
||||||
|
|
|
@ -461,14 +461,17 @@ insertFixmeExported h item = do
|
||||||
on conflict (o, k)
|
on conflict (o, k)
|
||||||
do update set
|
do update set
|
||||||
v = case
|
v = case
|
||||||
when excluded.w > object.w and (excluded.v <> object.v) then excluded.v
|
when excluded.w > object.w then excluded.v
|
||||||
else object.v
|
else object.v
|
||||||
end,
|
end,
|
||||||
w = case
|
w = case
|
||||||
when excluded.w > object.w and (excluded.v <> object.v) then excluded.w
|
when excluded.w > object.w then excluded.w
|
||||||
else object.w
|
else object.w
|
||||||
end,
|
end,
|
||||||
nonce = excluded.nonce
|
nonce = case
|
||||||
|
when excluded.w > object.w then excluded.nonce
|
||||||
|
else object.nonce
|
||||||
|
end
|
||||||
|]
|
|]
|
||||||
|
|
||||||
insert sql (WithNonce h item)
|
insert sql (WithNonce h item)
|
||||||
|
|
Loading…
Reference in New Issue