-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add daily import zetkin job #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { DataSourceType } from "@/models/DataSource"; | ||
| import { findDataSourcesByType } from "@/server/repositories/DataSource"; | ||
| import logger from "../services/logger"; | ||
| import { enqueue } from "../services/queue"; | ||
|
|
||
| const importZetkinDataSources = async (): Promise<boolean> => { | ||
| const zetkinDataSources = await findDataSourcesByType(DataSourceType.Zetkin); | ||
| for (const source of zetkinDataSources) { | ||
| try { | ||
| await enqueue("importDataSource", source.id, { | ||
| dataSourceId: source.id, | ||
| }); | ||
|
Comment on lines
+6
to
+12
|
||
| } catch (error) { | ||
| logger.warn( | ||
| `Failed to enqueue import for Zetkin data source ${source.id}`, | ||
| { error }, | ||
| ); | ||
| continue; | ||
| } | ||
| } | ||
| return true; | ||
|
Comment on lines
+8
to
+21
|
||
| }; | ||
|
|
||
| export default importZetkinDataSources; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schedule()ultimately callsboss.schedule(queue, ...). With pg-boss, the first argument is the schedule/job name and must be unique; scheduling twice with the same name (here: the default queue name) will overwrite/update the existing schedule. As written, the 4:00am schedule will replace the 3:00amrefreshWebhooksschedule (or vice-versa), so only one of them will actually run. Use distinct schedule names per task (e.g., incorporatetaskinto the scheduled job name), or change the scheduling approach so multiple cron tasks can coexist on the same queue.