Merge branch 'fix_update_users' into legacy_dev
All checks were successful
All checks were successful
This commit is contained in:
commit
6cca4e0fd5
@ -222,6 +222,7 @@ export default class IdNotService extends BaseService {
|
|||||||
public async updateUser(userId: string) {
|
public async updateUser(userId: string) {
|
||||||
const userInfos = await this.userService.getByUid(userId, { contact: true, role: true, office_membership: true });
|
const userInfos = await this.userService.getByUid(userId, { contact: true, role: true, office_membership: true });
|
||||||
const user = User.hydrate<User>(userInfos!);
|
const user = User.hydrate<User>(userInfos!);
|
||||||
|
console.log("Got user from db:", JSON.stringify(user));
|
||||||
const searchParams = new URLSearchParams({
|
const searchParams = new URLSearchParams({
|
||||||
key: this.variables.IDNOT_API_KEY,
|
key: this.variables.IDNOT_API_KEY,
|
||||||
});
|
});
|
||||||
@ -238,11 +239,11 @@ export default class IdNotService extends BaseService {
|
|||||||
)
|
)
|
||||||
).json()) as IRattachementData;
|
).json()) as IRattachementData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching user data", error);
|
console.error(`Error fetching user data for ${user.uid}: ${error}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("First userData", JSON.stringify(userData));
|
console.log("Got userData from idnot", JSON.stringify(userData));
|
||||||
|
|
||||||
if (userData.deleted) {
|
if (userData.deleted) {
|
||||||
let rattachements: any;
|
let rattachements: any;
|
||||||
@ -282,6 +283,7 @@ export default class IdNotService extends BaseService {
|
|||||||
|
|
||||||
if (officeData.typeEntite.name === "office") {
|
if (officeData.typeEntite.name === "office") {
|
||||||
userData = rattachement;
|
userData = rattachement;
|
||||||
|
console.log("Updated userData", JSON.stringify(userData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -289,9 +291,6 @@ export default class IdNotService extends BaseService {
|
|||||||
|
|
||||||
let updates = 0;
|
let updates = 0;
|
||||||
|
|
||||||
console.log("Second userData", JSON.stringify(userData));
|
|
||||||
console.log("BDD user", JSON.stringify(user));
|
|
||||||
|
|
||||||
|
|
||||||
if (user.office_membership!.idNot !== userData.entite.ou) {
|
if (user.office_membership!.idNot !== userData.entite.ou) {
|
||||||
updates++;
|
updates++;
|
||||||
@ -366,9 +365,6 @@ export default class IdNotService extends BaseService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const officeData = (await officeRawData.json()) as IOfficeData;
|
const officeData = (await officeRawData.json()) as IOfficeData;
|
||||||
console.log("office", office);
|
|
||||||
|
|
||||||
console.log("officeData", officeData);
|
|
||||||
|
|
||||||
let updates = 0;
|
let updates = 0;
|
||||||
//093051 = demo
|
//093051 = demo
|
||||||
@ -380,6 +376,7 @@ export default class IdNotService extends BaseService {
|
|||||||
updates++;
|
updates++;
|
||||||
office.office_status = this.getOfficeStatus(officeData.statutEntite.name);
|
office.office_status = this.getOfficeStatus(officeData.statutEntite.name);
|
||||||
}
|
}
|
||||||
|
console.log(`Updating office: ${office.uid} - ${office.name} - ${office.crpcen}`);
|
||||||
if (updates != 0) await this.officeService.update(office.uid!, office);
|
if (updates != 0) await this.officeService.update(office.uid!, office);
|
||||||
await this.officeService.updateCheckedAt(office.uid!);
|
await this.officeService.updateCheckedAt(office.uid!);
|
||||||
}
|
}
|
||||||
@ -556,6 +553,7 @@ export default class IdNotService extends BaseService {
|
|||||||
public async updateOffices() {
|
public async updateOffices() {
|
||||||
const officesReq = await this.officeService.getOfficesToBeChecked();
|
const officesReq = await this.officeService.getOfficesToBeChecked();
|
||||||
const offices = Office.hydrateArray<Office>(officesReq);
|
const offices = Office.hydrateArray<Office>(officesReq);
|
||||||
|
console.log(`Updating ${offices.length} offices`);
|
||||||
offices.forEach(async (office) => {
|
offices.forEach(async (office) => {
|
||||||
await this.updateOffice(office.uid!);
|
await this.updateOffice(office.uid!);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user