Skip to content

Commit

Permalink
update toad-scheduler to 3.0
Browse files Browse the repository at this point in the history
modify logging to error
  • Loading branch information
im-calvin committed Nov 2, 2023
1 parent 1cb167b commit d269fb6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"pagination.djs": "^4.0.10",
"reflect-metadata": "^0.1.13",
"sqlite3": "^5.1.6",
"toad-scheduler": "^2.2.0",
"toad-scheduler": "3.0",
"typeorm": "^0.3.16"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/db/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const AppDataSource = new DataSource({
type: "sqlite",
database: "data/database.sqlite",
synchronize: false,
logging: "all",
logging: ["error"],
entities: [
Video,
DiscordUser,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export async function scrape() {
},
});

const streamerIds: Set<String> = new Set(streamers.map((s: Streamer) => s.id));

const task = new AsyncTask("scrape Holodex", async () => {
// fetch all upcoming streams from holodex
// relevant docs: https://holodex.stoplight.io/docs/holodex/f1e355dc4cb79-quickly-access-live-upcoming-for-a-set-of-channels
Expand All @@ -80,10 +82,9 @@ export async function scrape() {
}
);
const videos: HolodexVideo[] = await response.json();

// add the data to the db
for (const video of videos) {
if (video.channel.org !== "Hololive") {
if (!streamerIds.has(video.channel.id)) {
continue; // TODO find a better workaround. Issue: when the original video creator is not from Hololive, the streamer isn't in the db and then it crashes
}
// videoMembers is the Video.members field in the db
Expand Down Expand Up @@ -136,7 +137,6 @@ export async function scrape() {
}
db_vid.participantStreamers = participants;

console.log("saving");
await videoRepo.save(db_vid);

// mention users for the 1st ping
Expand Down

0 comments on commit d269fb6

Please sign in to comment.