Skip to content

Commit

Permalink
[TECH] Suppression des scripts de conversion des centres en V3 (PIX-1…
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-service-auto-merge authored Nov 15, 2024
2 parents 03da276 + c6c37b9 commit e1d362a
Show file tree
Hide file tree
Showing 27 changed files with 1 addition and 1,306 deletions.
55 changes: 0 additions & 55 deletions api/scripts/certification/next-gen/convert-all-centers-to-v3.js

This file was deleted.

37 changes: 0 additions & 37 deletions api/scripts/certification/next-gen/convert-centers-to-v3.js

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions api/src/certification/configuration/domain/usecases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import * as attachableTargetProfileRepository from '../../infrastructure/reposit
import * as candidateRepository from '../../infrastructure/repositories/candidate-repository.js';
import * as centerPilotFeaturesRepository from '../../infrastructure/repositories/center-pilot-features-repository.js';
import * as centerRepository from '../../infrastructure/repositories/center-repository.js';
/**
* @typedef {import('../../infrastructure/repositories/index.js').SessionsRepository} SessionsRepository
*/
import { configurationRepositories } from '../../infrastructure/repositories/index.js';
import { convertCenterToV3JobRepository } from '../../infrastructure/repositories/jobs/convert-center-to-v3-job-repository.js';

/**
*
Expand All @@ -22,17 +17,13 @@ import { convertCenterToV3JobRepository } from '../../infrastructure/repositorie
* @typedef {attachableTargetProfileRepository} AttachableTargetProfileRepository
* @typedef {centerPilotFeaturesRepository} CenterPilotFeaturesRepository
* @typedef {centerRepository} CentersRepository
* @typedef {convertCenterToV3JobRepository} ConvertCenterToV3JobRepository
* @typedef {sessionsRepository} SessionsRepository
* @typedef {candidateRepository} CandidateRepository
**/
const dependencies = {
attachableTargetProfileRepository,
complementaryCertificationRepository,
centerPilotFeaturesRepository,
centerRepository,
convertCenterToV3JobRepository,
sessionsRepository: configurationRepositories.sessionsRepository,
candidateRepository,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
import { DomainTransaction } from '../../../../shared/domain/DomainTransaction.js';
import { DEFAULT_PAGINATION } from '../../../../shared/infrastructure/utils/knex-utils.js';
import { logger } from '../../../../shared/infrastructure/utils/logger.js';
import { Center } from '../../domain/models/Center.js';
import { CenterTypes } from '../../domain/models/CenterTypes.js';

/**
* @param {Object} params
* @param {number} params.[cursorId] - identifies the primary identifier above with the results will be taken (cursor pagination). If empty, will start from beginning
* @param {number} params.[size] - number of centers to fetch
* @returns {Array<Center>} centers primary identifiers found ordered by ascending identifiers
*/
export const findSCOV2Centers = async function ({ cursorId, size = DEFAULT_PAGINATION.PAGE_SIZE } = {}) {
logger.debug('cursorId:[%o]', cursorId);
const knexConn = DomainTransaction.getConnection();
const query = knexConn
.from('certification-centers')
.select('certification-centers.id', 'certification-centers.externalId')
.where({ isV3Pilot: false, type: CenterTypes.SCO })
.orderBy('certification-centers.id', 'ASC')
.limit(size);

if (cursorId) {
query.andWhere('certification-centers.id', '>', cursorId);
}

const results = await query;
return results.map(({ id, externalId }) => _toDomain({ id, externalId, type: CenterTypes.SCO }));
};

const _toDomain = ({ id, externalId, type }) => {
return new Center({ id, externalId, type });
};

/**
* @param {Object} params
* @param {Array<number>} params.externalIds
Expand All @@ -54,33 +23,3 @@ export const resetWhitelist = async () => {
.update({ isScoBlockedAccessWhitelist: false, updatedAt: knexConn.fn.now() })
.where({ type: CenterTypes.SCO });
};

/**
* @param {Object} params
* @param {Array<number>} params.preservedCenterIds
* @returns {Promise<number>} updated centers count
*/
export const updateCentersToV3 = async ({ preservedCenterIds }) => {
const knexConn = DomainTransaction.getConnection();
const results = await knexConn('certification-centers')
.update({ isV3Pilot: true, updatedAt: knexConn.fn.now() }, ['id'])
.where({ isV3Pilot: false })
.whereNotIn('id', preservedCenterIds);

return results.length;
};

/**
* @param {Object} params
* @param {Array<number>} params.preservedCenterIds
* @returns {Promise<Array<number>>} v2 center ids excluding preservedCenterIds
*/
export const findV2CenterIds = async ({ preservedCenterIds }) => {
const knexConn = DomainTransaction.getConnection();
const centers = await knexConn('certification-centers')
.select('id')
.where({ isV3Pilot: false })
.whereNotIn('id', preservedCenterIds);

return centers.map(({ id }) => id);
};

This file was deleted.

Loading

0 comments on commit e1d362a

Please sign in to comment.