Files
captoys/diigo-cache/src/cache-read.sql
T
dckc 002f08b456 diigo-cache: date windows and search on the public page (1d)
/public/<username> takes days, after, before, in (year, month,
quarter, ISO week), by=updated|created, and q (words, "phrases",
#tags, -negation, gmail/Slack/GitHub date operators). JSON answers
echo the parsed filter; a malformed one is a 400.

Filters query the stored items in sqlite through the read-only
viewer instead of walking diigo pages: the public page keeps no
fetch authority, and a filled cache already holds every item.
Results say `complete` when every diigo page is stored; freshness
is 1f's head refresh. So the fetch budget and the O(log pages)
walk test go, and the fake deep account shrinks to 300.

Generated-by: Claude Opus 5.5
2026-10-09 01:17:03 -05:00

33 lines
985 B
SQL

-- pageHeader:
select total, etched_at from pages where page_num = ? and count = ?;
-- pageItems:
select items.json
from page_members
join items on items.item_id = page_members.item_id
where page_members.page_num = ?
order by page_members.pos;
-- knownTotal:
select total from pages where total > 0 order by etched_at desc limit 1;
-- deepestPageSince:
select max(page_members.page_num) as last
from page_members
join items on items.item_id = page_members.item_id
where cast(items.updated as integer) >= ?;
-- pagesThrough:
select count(*) as n from pages where page_num <= ?;
-- itemsByUpdated:
select json from items
where cast(updated as integer) >= ? and cast(updated as integer) < ?
order by cast(updated as integer) desc, item_id;
-- itemsByCreated:
select json from items
where cast(json_extract(json, '$.created_at') as integer) >= ?
and cast(json_extract(json, '$.created_at') as integer) < ?
order by cast(json_extract(json, '$.created_at') as integer) desc, item_id;