debug: añade logging temporal para diagnóstico de sincronización

pull/1/head
borja (aider) 4 months ago committed by borja
parent ff0923f3cb
commit 6e4720d7cd

@ -74,11 +74,33 @@ export class GroupSyncService {
}
const groups = await this.fetchGroupsFromAPI();
const communityGroups = groups.filter(
(group) => group.linkedParent === communityId
);
console.log(' Grupos crudos de la API:', JSON.stringify(groups, null, 2));
const communityGroups = groups.filter((group) => {
const matches = group.linkedParent === communityId;
console.log(` Grupo ${group.id} (${group.subject}):`, {
linkedParent: group.linkedParent,
matchesCommunity: matches,
isCommunityItself: group.id === communityId
});
return matches;
});
console.log(' Grupos que pasaron el filtro:', communityGroups.map(g => ({
id: g.id,
name: g.subject,
parent: g.linkedParent
})));
const dbGroupsBefore = db.prepare('SELECT id, active FROM groups').all();
console.log(' Grupos en DB antes de upsert:', dbGroupsBefore);
return await this.upsertGroups(communityGroups);
const result = await this.upsertGroups(communityGroups);
const dbGroupsAfter = db.prepare('SELECT id, active FROM groups').all();
console.log(' Grupos en DB después de upsert:', dbGroupsAfter);
return result;
} catch (error) {
console.error('Group sync failed:', error);
throw error;
@ -259,8 +281,12 @@ export class GroupSyncService {
UPDATE groups
SET active = FALSE,
last_verified = CURRENT_TIMESTAMP
WHERE active = TRUE
`).run();
console.log('Marked groups inactive:', inactiveResult);
console.log(' Grupos marcados como inactivos:', {
count: inactiveResult.changes,
lastId: inactiveResult.lastInsertRowid
});
for (const group of groups) {
const existing = db.prepare('SELECT 1 FROM groups WHERE id = ?').get(group.id);

Loading…
Cancel
Save