Skip to content

Commit

Permalink
Add tag links 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 02dd1cc commit fd10baa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion fimficstats/fimfic-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function mane() {
const request_interval = 1000;

// Loop over IDs to scrape data.
for (let id = 551751; id < 552652; id++) {
for (let id = 551751; id <= 553110; id++) {
const start_time = Date.now();
let status = "unknown";

Expand Down Expand Up @@ -171,6 +171,7 @@ async function mane() {
tag.href.replace("/tag/", ""),
),
).run();
db.query(sql.insert_tag_link(id, tag.id)).run();
});

await sleep(start_time, Date.now(), request_interval);
Expand Down
7 changes: 6 additions & 1 deletion fimficstats/sql-patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function insert_tag(
VALUES (${id}, '${title}', '${type}', '${text}', '${href}')`;
}

export const tag_links_table = `CREATE TABLE IF NOT EXISTS Tags_links (
export const tag_links_table = `CREATE TABLE IF NOT EXISTS Tag_links (
story_id integer,
tag_id integer,
Expand All @@ -133,6 +133,11 @@ export const tag_links_table = `CREATE TABLE IF NOT EXISTS Tags_links (
CONSTRAINT tag_links_pk PRIMARY KEY (story_id, tag_id)
)`;

export function insert_tag_link(story_id: number, tag_id: number) {
return `INSERT OR IGNORE INTO Tag_links (story_id, tag_id)
VALUES (${story_id}, ${tag_id})`;
}

export const chapters_table = `CREATE TABLE IF NOT EXISTS Chapters (
story_id integer NOT NULL,
chapter_num integer NOT NULL,
Expand Down

0 comments on commit fd10baa

Please sign in to comment.