Compare commits
2 Commits
087dd0cd24
...
6cca4e0fd5
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6cca4e0fd5 | ||
![]() |
463327e6a1 |
@ -222,6 +222,7 @@ export default class IdNotService extends BaseService {
|
||||
public async updateUser(userId: string) {
|
||||
const userInfos = await this.userService.getByUid(userId, { contact: true, role: true, office_membership: true });
|
||||
const user = User.hydrate<User>(userInfos!);
|
||||
console.log("Got user from db:", JSON.stringify(user));
|
||||
const searchParams = new URLSearchParams({
|
||||
key: this.variables.IDNOT_API_KEY,
|
||||
});
|
||||
@ -238,11 +239,11 @@ export default class IdNotService extends BaseService {
|
||||
)
|
||||
).json()) as IRattachementData;
|
||||
} catch (error) {
|
||||
console.error("Error fetching user data", error);
|
||||
console.error(`Error fetching user data for ${user.uid}: ${error}`);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("First userData", JSON.stringify(userData));
|
||||
console.log("Got userData from idnot", JSON.stringify(userData));
|
||||
|
||||
if (userData.deleted) {
|
||||
let rattachements: any;
|
||||
@ -282,6 +283,7 @@ export default class IdNotService extends BaseService {
|
||||
|
||||
if (officeData.typeEntite.name === "office") {
|
||||
userData = rattachement;
|
||||
console.log("Updated userData", JSON.stringify(userData));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -289,9 +291,6 @@ export default class IdNotService extends BaseService {
|
||||
|
||||
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) {
|
||||
updates++;
|
||||
@ -366,9 +365,6 @@ export default class IdNotService extends BaseService {
|
||||
return;
|
||||
}
|
||||
const officeData = (await officeRawData.json()) as IOfficeData;
|
||||
console.log("office", office);
|
||||
|
||||
console.log("officeData", officeData);
|
||||
|
||||
let updates = 0;
|
||||
//093051 = demo
|
||||
@ -380,6 +376,7 @@ export default class IdNotService extends BaseService {
|
||||
updates++;
|
||||
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);
|
||||
await this.officeService.updateCheckedAt(office.uid!);
|
||||
}
|
||||
@ -556,6 +553,7 @@ export default class IdNotService extends BaseService {
|
||||
public async updateOffices() {
|
||||
const officesReq = await this.officeService.getOfficesToBeChecked();
|
||||
const offices = Office.hydrateArray<Office>(officesReq);
|
||||
console.log(`Updating ${offices.length} offices`);
|
||||
offices.forEach(async (office) => {
|
||||
await this.updateOffice(office.uid!);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user