Annotation For rsstg.sql
Logged in as anonymous

Lines of rsstg.sql from check-in f322efafd9 that are changed by the sequence of edits moving toward check-in 4e0a19d772:

                         1: create table rsstg_updates (owner integer, update jsonb);
                         2: 
                         3: create unique index rsstg_updates__id on rsstg_updates(update->>'update_id');
                         4: 
                         5: create table rsstg_source (
                         6: 	source_id serial,
                         7: 	channel text not null,
                         8: 	channel_id integer not null,
                         9: 	url text not null,
                        10: 	last_scrape not null timestamptz default now(),
                        11: 	enabled boolean not null default false,
                        12: 	iv_hash text,
                        13: 	owner bigint not null);
                        14: create unique index rsstg_source__source_id on rsstg_source(source_id);
                        15: create unique index rsstg_source__channel_id__owner on rsstg_source(channel_id, owner);
                        16: create index rsstg_source__owner on rsstg_source(owner);
                        17: 
                        18: create table rsstg_post (
                        19: 	source_id integer not null,
f322efafd9 2020-11-30   20: 	date int not null,
                        21: 	url text not null,
f322efafd9 2020-11-30   22: 	hour smallint not null generated always as (extract('hour' from  posted)) stored,
                        23: 	FOREIGN KEY (source_id) REFERENCES rsstg_source(source_id) on delete cascade,
                        24: );
                        25: create unique index rsstg_post__url on rsstg_post(url);
                        26: create index rsstg_post__hour on rsstg_post(hour);
                        27: create index rsstg_post__posted_hour on rsstg_post(posted,hour);
                        28: 
                        29: create or replace view rsstg_order as
                        30: 	select source_id, coalesce(last_scrape + make_interval(0,0,0,0,0,(60 / (coalesce(activity, 1)/7 + 1) )::integer), now() - interval '1 minute') as next_fetch, owner
                        31: 		from rsstg_source natural left join
                        32: 		(select source_id, count(*) as activity
                        33: 			from rsstg_post where 
f322efafd9 2020-11-30   34: 				hour = extract('hour' from now())::smallint
                        35: 				and posted > now() - interval '7 days'
                        36: 			group by source_id) as act
                        37: 		where enabled
                        38: 		order by next_fetch;