Skip to content

Commit 2aeeb1a

Browse files
authored
Merge pull request #16 from fabmob/1.21.2
Programme Mon Compte Mobilité - Version 1.21.2
2 parents 722fdad + 9662c0a commit 2aeeb1a

File tree

9 files changed

+95
-9
lines changed

9 files changed

+95
-9
lines changed

administration/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "administration",
3-
"version": "1.21.0",
3+
"version": "1.21.2",
44
"author": "Mon Compte Mobilité",
55
"private": true,
66
"dependencies": {

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mcm/mcm-api",
3-
"version": "1.21.0",
3+
"version": "1.21.2",
44
"description": "",
55
"keywords": [
66
"loopback-application",

api/src/application.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ import {MongoDsDataSource} from './datasources';
2424
import {LoggerProvider} from './providers';
2525
import {Logger} from './utils';
2626
import {LoggerBindings} from './keys';
27-
import {MigrationScript1210} from './migrations/1.21.0.migration';
2827
import {
2928
RabbitmqCronJob,
3029
SubscriptionCronJob,
3130
NonActivatedAccountDeletionCronJob,
3231
InactiveAccountNotificationCronJob,
3332
InactiveAccountDeletionCronJob,
3433
} from './cronjob';
34+
import {MigrationScript1212} from './migrations/1.21.2.migration';
3535

3636
export class App extends BootMixin(ServiceMixin(RepositoryMixin(RestApplication))) {
3737
constructor(options: ApplicationConfig = {}) {
@@ -69,10 +69,10 @@ export class App extends BootMixin(ServiceMixin(RepositoryMixin(RestApplication)
6969
this.static('/', path.join(__dirname, '../public'));
7070
// Configure migration componentcd
7171
this.bind(MigrationBindings.CONFIG).to({
72-
appVersion: '1.21.0',
72+
appVersion: '1.21.2',
7373
dataSourceName: MongoDsDataSource.dataSourceName,
7474
modelName: 'Migration',
75-
migrationScripts: [MigrationScript1210],
75+
migrationScripts: [MigrationScript1212],
7676
});
7777
// Bind migration component related elements
7878
this.component(MigrationComponent);
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import {MigrationScript, migrationScript} from 'loopback4-migration';
2+
import {repository} from '@loopback/repository';
3+
import {GROUPS, Logger} from '../utils';
4+
import {service} from '@loopback/core';
5+
import {KeycloakService} from '../services';
6+
import {UserEntityRepository} from '../repositories';
7+
import {Citizen, UserEntity} from '../models';
8+
9+
@migrationScript()
10+
export class MigrationScript1212 implements MigrationScript {
11+
version = '1.21.2';
12+
scriptName = MigrationScript1212.name;
13+
description = 'Update Citizen with lastLoginAt, tos1 & tos2 timestamp';
14+
15+
constructor(
16+
@repository(UserEntityRepository)
17+
public userEntityRepository: UserEntityRepository,
18+
@service(KeycloakService)
19+
public keycloakService: KeycloakService,
20+
) {}
21+
22+
sliceIntoChunks = (array: any[], chunkSize: number): any[][] => {
23+
const res = [];
24+
for (let i = 0; i < array.length; i += chunkSize) {
25+
const chunk = array.slice(i, i + chunkSize);
26+
res.push(chunk);
27+
}
28+
return res;
29+
};
30+
31+
async up(): Promise<void> {
32+
Logger.info(MigrationScript1212.name, this.up.name, 'Started');
33+
34+
const citizenToUpdateList: UserEntity[] =
35+
await this.userEntityRepository.searchUserWithAttributesByFilter({}, GROUPS.citizens);
36+
37+
Logger.info(
38+
MigrationScript1212.name,
39+
this.up.name,
40+
'Number of citizen to update',
41+
citizenToUpdateList.length,
42+
);
43+
44+
const citizenToUpdateChunkList: UserEntity[][] = this.sliceIntoChunks(citizenToUpdateList, 10);
45+
46+
for (const citizenToUpdateChunk of citizenToUpdateChunkList) {
47+
await Promise.allSettled(
48+
citizenToUpdateChunk.map(async (citizenToUpdate: UserEntity) => {
49+
try {
50+
Logger.info(MigrationScript1212.name, this.up.name, `Start update citizen`, citizenToUpdate.id);
51+
52+
const citizen: Citizen = citizenToUpdate.toCitizen();
53+
if (!citizen.lastLoginAt || !citizen.tos1 || !citizen.tos2) {
54+
if (!citizen.lastLoginAt) {
55+
citizen.lastLoginAt = citizen.updatedAt;
56+
}
57+
if (!citizen.tos1 || !citizen.tos2) {
58+
citizen.tos1 = true;
59+
citizen.tos2 = true;
60+
}
61+
await this.keycloakService.updateUserKC(citizen.id, citizen);
62+
Logger.info(MigrationScript1212.name, this.up.name, `Citizen Updated`, citizenToUpdate.id);
63+
} else {
64+
Logger.info(
65+
MigrationScript1212.name,
66+
this.up.name,
67+
`Citizen has lastLoginAt, tos1 & tos2 property`,
68+
citizenToUpdate.id,
69+
);
70+
}
71+
} catch (err) {
72+
Logger.error(
73+
MigrationScript1212.name,
74+
this.up.name,
75+
`Error while updating citizen`,
76+
citizenToUpdate.id,
77+
);
78+
}
79+
}),
80+
);
81+
}
82+
83+
Logger.info(MigrationScript1212.name, this.up.name, `Completed`);
84+
}
85+
}

commons/.gitlab-ci/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ mongo_testing_clean_data:
236236
fi
237237
echo "---------"
238238
echo "GET GROUPS"
239-
GROUP_LIST_ID=$(kubectl exec $IDP_POD_NAME -n $IDP_NAMESPACE -c idp -- sh -c "/opt/jboss/keycloak/bin/kcadm.sh get groups -r mcm" | jq -r '.[] | select( .name == "entreprises" or .name == "collectivités") | .subGroups | .[] | .id')
239+
GROUP_LIST_ID=$(kubectl exec $IDP_POD_NAME -n $IDP_NAMESPACE -c idp -- sh -c "/opt/jboss/keycloak/bin/kcadm.sh get groups -r mcm" | jq -r '.[] | select( .name == "entreprises" or .name == "collectivités" or .name == "administrations_nationales") | .subGroups | .[] | .id')
240240
echo $GROUP_LIST_ID
241241
if [ -z "$GROUP_LIST_ID" ]
242242
then

helm-chart/antivirus-values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ autoscaling:
5656
policies:
5757
- type: Pods
5858
value: 1
59+
periodSeconds: 300
5960

6061
deployments:
6162
- metadata:

simulation-maas/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simulation-maas",
3-
"version": "1.21.0",
3+
"version": "1.21.2",
44
"description": "here is a maas simulator",
55
"main": "index.js",
66
"scripts": {

test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cypress-mcm",
3-
"version": "1.21.0",
3+
"version": "1.21.2",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@mcm/mcm-website",
33
"description": "JAMstack project based on Gatsby and Netlify CMS",
4-
"version": "1.21.0",
4+
"version": "1.21.2",
55
"author": "Capgemini",
66
"dependencies": {
77
"@datapunt/matomo-tracker-react": "0.5.1",

0 commit comments

Comments
 (0)