-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Manuel Ruck <[email protected]>
- Loading branch information
Manuel Ruck
committed
Oct 22, 2023
1 parent
3d2c7c7
commit 46481f3
Showing
38 changed files
with
197 additions
and
665 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
import Mongoose from "mongoose"; | ||
import Mongoose from 'mongoose'; | ||
const mongoose = Mongoose; | ||
export { mongoose }; | ||
|
||
export const mongoConnect = async () => | ||
new Promise(async (resolve) => { | ||
// Mongo Debug | ||
mongoose.set('debug', false); | ||
|
||
mongoose.connect(process.env.DB_URL!); | ||
|
||
mongoose.connection.once('connected', () => { | ||
console.info('MongoDB is running'); | ||
resolve(true); | ||
}); | ||
mongoose.connection.on('error', (e: Error) => { | ||
// Unknown if this ends up in main - therefore we log here | ||
console.error(e.stack); | ||
throw e; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
export * from "./mongoose"; | ||
export * from "./activity"; | ||
export * from "./cronjob"; | ||
export * from "./deputy"; | ||
export * from "./device"; | ||
export * from "./document"; | ||
export * from "./phone"; | ||
export * from "./procedure"; | ||
export * from "./pushNotification"; | ||
export * from "./search-term"; | ||
export * from "./user"; | ||
export * from "./verification"; | ||
export * from "./vote"; | ||
export * from './mongoose'; | ||
export * from './activity'; | ||
export * from './cronjob'; | ||
export * from './deputy'; | ||
export * from './device'; | ||
export * from './document'; | ||
export * from './phone'; | ||
export * from './procedure'; | ||
export * from './pushNotification'; | ||
export * from './search-term'; | ||
export * from './user'; | ||
export * from './verification'; | ||
export * from './vote'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
import Mongoose from "mongoose"; | ||
import Mongoose from 'mongoose'; | ||
const mongoose = Mongoose; | ||
export { mongoose }; | ||
|
||
export const mongoConnect = async () => | ||
new Promise(async (resolve) => { | ||
// Mongo Debug | ||
mongoose.set('debug', false); | ||
|
||
mongoose.connect(process.env.DB_URL!); | ||
|
||
mongoose.connection.once('connected', () => { | ||
console.info('MongoDB is running'); | ||
resolve(true); | ||
}); | ||
mongoose.connection.on('error', (e: Error) => { | ||
// Unknown if this ends up in main - therefore we log here | ||
console.error(e.stack); | ||
throw e; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
46 changes: 12 additions & 34 deletions
46
services/cron-jobs/crawler/src/import-procedures/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,17 @@ | ||
import { mongoConnect, mongoDisconnect } from '../mongoose'; | ||
import { getCron, setCronError, setCronStart, setCronSuccess } from '@democracy-deutschland/bundestagio-common'; | ||
import { getCron, mongoConnect, setCronStart, setCronSuccess } from '@democracy-deutschland/bundestagio-common'; | ||
import config from '../config'; | ||
import importProcedures from './import-procedures'; | ||
import debug from 'debug'; | ||
const error = debug('bundestag-io:import-procedures:error'); | ||
|
||
(async () => { | ||
let withError = false; | ||
try { | ||
await mongoConnect(); | ||
const cronjob = await getCron({ name: 'import-procedures' }); | ||
await setCronStart({ name: 'import-procedures' }); | ||
await importProcedures({ | ||
...config, | ||
IMPORT_PROCEDURES_FILTER_AFTER: | ||
// cronjob?.lastSuccessDate?.toISOString().slice(0, 10) || | ||
config.IMPORT_PROCEDURES_FILTER_AFTER, | ||
}); | ||
await setCronSuccess({ name: 'import-procedures', successStartDate: cronjob.lastStartDate || new Date() }); | ||
} catch (err) { | ||
withError = true; | ||
error(err); | ||
try { | ||
if (typeof err === 'string') { | ||
await setCronError({ name: 'import-procedures', error: err }); | ||
} else { | ||
console.error(err); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} finally { | ||
mongoDisconnect(); | ||
} | ||
if (withError) { | ||
process.exit(1); | ||
} | ||
await mongoConnect(); | ||
const cronjob = await getCron({ name: 'import-procedures' }); | ||
await setCronStart({ name: 'import-procedures' }); | ||
await importProcedures({ | ||
...config, | ||
IMPORT_PROCEDURES_FILTER_AFTER: | ||
// cronjob?.lastSuccessDate?.toISOString().slice(0, 10) || | ||
config.IMPORT_PROCEDURES_FILTER_AFTER, | ||
}); | ||
await setCronSuccess({ name: 'import-procedures', successStartDate: cronjob.lastStartDate || new Date() }); | ||
process.exit(0); | ||
})(); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.