Skip to content

Commit

Permalink
Add referral sites insertion to fimfic stats
Browse files Browse the repository at this point in the history
  • Loading branch information
SilkRose committed Mar 11, 2024
1 parent 485cb43 commit d0bb13e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions fimficstats/fimfic-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ async function mane() {
).run();
});

for (const site in referrals) {
db.query(sql.insert_referral_site(site)).run();
}

await sleep(start_time, Date.now(), request_interval);
}
}
Expand Down
9 changes: 8 additions & 1 deletion fimficstats/sql-patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,16 @@ export function insert_stats(

export const referral_sites_table = `CREATE TABLE IF NOT EXISTS Referral_sites (
id integer PRIMARY KEY,
site string NOT NULL
site string NOT NULL,
UNIQUE(site)
)`;

export function insert_referral_site(site: string) {
return `INSERT OR IGNORE INTO Referral_sites (site)
VALUES ('${site}')`;
}

export const referrals_table = `CREATE TABLE IF NOT EXISTS Referrals (
story_id integer NOT NULL,
referral_site_id integer NOT NULL,
Expand Down

0 comments on commit d0bb13e

Please sign in to comment.