-
Notifications
You must be signed in to change notification settings - Fork 56
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
[TECH] Enregistrer l'historique des réplications des données froides (PIX-16710)(PIX-16712). #11527
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
eae31d2
feat: adds maddo jobgroup in pgboss and maddo worker
nlepage 5e9c974
feat(maddo): runs replications in pgboss jobs
nlepage b195044
feat(api): add replications for certifications_results
VincentHardouin 2c4a378
feat(maddo): return line count at the end of the replication job
aurelie-crouillebois 3f7da9e
chore: close db connections when worker is stopped
HEYGUL 2fcd747
refactor: renames maddo.js to index.maddo.js
nlepage 4b52bdc
refactor: inverts control in worker.js
nlepage 5d4cc4a
feat(api): process maddo pgboss jobs in maddo server
nlepage 7680ef3
feat(api): validate environment variables in workers
nlepage 1102e8b
chore: ignores api/datamart/migrations in lslint
nlepage File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -29,6 +29,7 @@ ls: | |
ignore: | ||
- .git | ||
- node_modules | ||
- datamart/migrations | ||
- db/migrations | ||
- db/seeds | ||
- scripts | ||
|
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
48 changes: 48 additions & 0 deletions
48
api/datamart/migrations/20250227142721_create-table-sco_certifications_results.js
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const TABLE_NAME = 'sco_certification_results'; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
const up = async function (knex) { | ||
await knex.schema.createTable(TABLE_NAME, function (table) { | ||
table.string('national_student_id'); | ||
table.index('national_student_id'); | ||
table.string('organization_uai'); | ||
table.string('last_name'); | ||
table.string('first_name'); | ||
table.date('birthdate'); | ||
table.text('status'); | ||
table.integer('pix_score'); | ||
table.timestamp('certification_date'); | ||
table.integer('competence_level'); | ||
table.index('organization_uai'); | ||
table.string('competence_name'); | ||
table.string('competence_code'); | ||
table.string('area_name'); | ||
table.string('certification_courses_id'); | ||
}); | ||
await knex.schema.raw('drop collation if exists "sco_certification_results_case_accent_punctuation_insensitive"'); | ||
await knex.schema.raw( | ||
'create collation "sco_certification_results_case_accent_punctuation_insensitive" (provider = icu, locale = "und-u-ka-shifted-ks-level1-kv-punct", deterministic = false);', | ||
); | ||
|
||
await knex.schema.raw( | ||
'ALTER TABLE :tableName: alter column first_name type varchar(255) COLLATE sco_certification_results_case_accent_punctuation_insensitive;', | ||
{ tableName: TABLE_NAME }, | ||
); | ||
await knex.schema.raw( | ||
'ALTER TABLE :tableName: alter column last_name type varchar(255) COLLATE sco_certification_results_case_accent_punctuation_insensitive;', | ||
{ tableName: TABLE_NAME }, | ||
); | ||
}; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
const down = async function (knex) { | ||
await knex.schema.dropTable(TABLE_NAME); | ||
}; | ||
|
||
export { down, up }; |
35 changes: 35 additions & 0 deletions
35
api/datamart/migrations/20250227142903_create-table-certification_results.js
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const TABLE_NAME = 'certification_results'; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
const up = async function (knex) { | ||
await knex.schema.createTable(TABLE_NAME, function (table) { | ||
table.string('certification_code_verification'); | ||
table.string('last_name'); | ||
table.string('first_name'); | ||
table.date('birthdate'); | ||
table.text('status'); | ||
table.integer('pix_score'); | ||
table.timestamp('certification_date'); | ||
table.integer('competence_level'); | ||
table.index('certification_code_verification'); | ||
table.string('competence_name'); | ||
table.string('competence_code'); | ||
table.string('area_name'); | ||
table.string('certification_courses_id'); | ||
table.string('national_student_id'); | ||
table.string('organization_uai'); | ||
}); | ||
}; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
const down = async function (knex) { | ||
await knex.schema.dropTable(TABLE_NAME); | ||
}; | ||
|
||
export { down, up }; |
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 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 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 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 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
25 changes: 25 additions & 0 deletions
25
api/src/maddo/application/jobs/replication-job-controller.js
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { knex as datamartKnex } from '../../../../datamart/knex-database-connection.js'; | ||
import { knex as datawarehouseKnex } from '../../../../datawarehouse/knex-database-connection.js'; | ||
import { JobController, JobGroup } from '../../../shared/application/jobs/job-controller.js'; | ||
import { ReplicationJob } from '../../domain/models/ReplicationJob.js'; | ||
import { extractTransformAndLoadData } from '../../domain/usecases/extract-transform-and-load-data.js'; | ||
import * as replicationRepository from '../../infrastructure/repositories/replication-repository.js'; | ||
|
||
export class ReplicationJobController extends JobController { | ||
constructor() { | ||
super(ReplicationJob.name, { jobGroup: JobGroup.MADDO }); | ||
} | ||
|
||
async handle({ | ||
data: { replicationName }, | ||
dependencies = { extractTransformAndLoadData, replicationRepository, datamartKnex, datawarehouseKnex }, | ||
}) { | ||
const { extractTransformAndLoadData, replicationRepository, datamartKnex, datawarehouseKnex } = dependencies; | ||
return extractTransformAndLoadData({ | ||
replicationName, | ||
replicationRepository, | ||
datamartKnex, | ||
datawarehouseKnex, | ||
}); | ||
} | ||
} |
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,47 +1,25 @@ | ||
import { knex as datamartKnex } from '../../../datamart/knex-database-connection.js'; | ||
import { knex as datawarehouseKnex } from '../../../datawarehouse/knex-database-connection.js'; | ||
import { logger } from '../../shared/infrastructure/utils/logger.js'; | ||
import { extractTransformAndLoadData } from '../domain/usecases/extract-transform-and-load-data.js'; | ||
import { ReplicationJob } from '../domain/models/ReplicationJob.js'; | ||
import { replicationJobRepository } from '../infrastructure/repositories/jobs/replication-job-repository.js'; | ||
import * as replicationRepository from '../infrastructure/repositories/replication-repository.js'; | ||
|
||
export async function replicate( | ||
request, | ||
h, | ||
dependencies = { | ||
extractTransformAndLoadData, | ||
replicationRepository, | ||
datamartKnex, | ||
datawarehouseKnex, | ||
logger, | ||
replicationJobRepository, | ||
}, | ||
) { | ||
const { replicationRepository, replicationJobRepository } = dependencies; | ||
const { replicationName } = request.params; | ||
|
||
const replication = dependencies.replicationRepository.getByName(replicationName); | ||
const replication = replicationRepository.getByName(replicationName); | ||
|
||
if (!replication) { | ||
return h.response().code(404); | ||
} | ||
|
||
const promise = dependencies | ||
.extractTransformAndLoadData({ | ||
replication, | ||
datamartKnex: dependencies.datamartKnex, | ||
datawarehouseKnex: dependencies.datawarehouseKnex, | ||
}) | ||
.catch((err) => | ||
dependencies.logger.error( | ||
{ | ||
event: 'replication', | ||
err, | ||
}, | ||
'Error during replication', | ||
), | ||
); | ||
|
||
if (!request.query.async) { | ||
await promise; | ||
} | ||
await replicationJobRepository.performAsync(new ReplicationJob({ replicationName })); | ||
|
||
return h.response().code(204); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export class ReplicationJob { | ||
constructor({ replicationName }) { | ||
this.replicationName = replicationName; | ||
} | ||
} |
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
4 changes: 4 additions & 0 deletions
4
api/src/maddo/infrastructure/repositories/jobs/replication-job-repository.js
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { JobRepository, JobRetry } from '../../../../shared/infrastructure/repositories/jobs/job-repository.js'; | ||
import { ReplicationJob } from '../../../domain/models/ReplicationJob.js'; | ||
|
||
export const replicationJobRepository = new JobRepository({ name: ReplicationJob.name, retry: JobRetry.FEW_RETRY }); |
51 changes: 50 additions & 1 deletion
51
api/src/maddo/infrastructure/repositories/replication-repository.js
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 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 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A revoir un de ces quatre pour éviter d'importer toutes les routes d'authent inutilement