Origin for each line in rsstg.sql from check-in 84130ab6bf:
61df933942 2020-11-18 1: create table rsstg_updates (owner integer, update jsonb); 61df933942 2020-11-18 2: 61df933942 2020-11-18 3: create unique index rsstg_updates__id on rsstg_updates(update->>'update_id'); 61df933942 2020-11-18 4: 61df933942 2020-11-18 5: -- create table rsstg_users (id integer); 61df933942 2020-11-18 6: create table rsstg_channel ( 61df933942 2020-11-18 7: channel_id bigint primary key, 075be7e40e 2020-11-18 8: username text not null); 61df933942 2020-11-18 9: create unique index rsstg_channel__username on rsstg_channel(username); 61df933942 2020-11-18 10: 61df933942 2020-11-18 11: create table rsstg_source ( 61df933942 2020-11-18 12: source_id serial, 61df933942 2020-11-18 13: channel_id integer not null, 61df933942 2020-11-18 14: url text not null, 075be7e40e 2020-11-18 15: last_scrape not null timestamptz default now(), 075be7e40e 2020-11-18 16: enabled boolean not null default false, 61df933942 2020-11-18 17: iv_hash text, 61df933942 2020-11-18 18: owner bigint not null); 61df933942 2020-11-18 19: create unique index rsstg_source__source_id on rsstg_source(source_id); 61df933942 2020-11-18 20: create unique index rsstg_source__channel_id__owner on rsstg_source(channel_id, owner); 61df933942 2020-11-18 21: create index rsstg_source__owner on rsstg_source(owner); 61df933942 2020-11-18 22: 61df933942 2020-11-18 23: create table rsstg_post ( 61df933942 2020-11-18 24: source_id integer not null, 61df933942 2020-11-18 25: date int not null, 61df933942 2020-11-18 26: url text not null, 075be7e40e 2020-11-18 27: hour smallint not null generated always as (extract('hour' from posted)) stored, 61df933942 2020-11-18 28: FOREIGN KEY (source_id) REFERENCES rsstg_source(source_id) 61df933942 2020-11-18 29: ); 61df933942 2020-11-18 30: create unique index rsstg_post__url on rsstg_post(url); 61df933942 2020-11-18 31: create index rsstg_post__hour on rsstg_post(hour); 0191d490fe 2020-11-18 32: create index rsstg_post__posted_hour on rsstg_post(posted,hour); 61df933942 2020-11-18 33: 61df933942 2020-11-18 34: create or replace view rsstg_order as 21d16a0993 2020-11-18 35: 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 61df933942 2020-11-18 36: from rsstg_source natural left join 61df933942 2020-11-18 37: (select source_id, count(*) as activity 61df933942 2020-11-18 38: from rsstg_post where 84130ab6bf 2020-11-20 39: hour = extract('hour' from now())::smallint 0191d490fe 2020-11-18 40: and posted > now() - interval '7 days' 61df933942 2020-11-18 41: group by source_id) as act 61df933942 2020-11-18 42: where enabled 61df933942 2020-11-18 43: order by next_fetch;