mirror of
https://github.com/laurent22/joplin.git
synced 2026-10-25 02:47:28 +00:00
Desktop, Mobile: Fix sync status incorrectly calculated for conflict notes (#16621)
This commit is contained in:
1 parent
227dbdedfc
commit
7fdcf1eabd
3 files changed
+37
-3
No files matched your search
@@ -586,6 +586,11 @@ export default class Note extends BaseItem {
|
||||
return r && r.total ? r.total : 0;
|
||||
}
|
||||
|
||||
public static async syncIneligibleConflictedCount() {
|
||||
const r = await this.db().selectOne('SELECT count(*) as total FROM notes WHERE is_conflict = 1 AND (conflict_original_id = "" OR share_id != "")');
|
||||
return r && r.total ? r.total : 0;
|
||||
}
|
||||
|
||||
// Count of notes that are eligible for indexing (anything searchable):
|
||||
// not trashed, not in conflict, and not locked. Used by the AI status reporter as the
|
||||
// denominator in "N / total indexed".
|
||||
|
||||
@@ -107,6 +107,34 @@ describe('ReportService', () => {
|
||||
await switchClient(1);
|
||||
});
|
||||
|
||||
it('should include sync-eligible conflict notes in sync status totals', async () => {
|
||||
const originalNote = await Note.save({ title: 'Original' });
|
||||
await Note.save({
|
||||
title: 'Sync-eligible conflict',
|
||||
is_conflict: 1,
|
||||
conflict_original_id: originalNote.id,
|
||||
});
|
||||
await Note.save({ title: 'Conflict without original', is_conflict: 1 });
|
||||
await Note.save({
|
||||
title: 'Trashed conflict without original',
|
||||
is_conflict: 1,
|
||||
deleted_time: Date.now(),
|
||||
});
|
||||
await Note.save({
|
||||
title: 'Shared conflict',
|
||||
is_conflict: 1,
|
||||
conflict_original_id: originalNote.id,
|
||||
share_id: 'share-id',
|
||||
});
|
||||
|
||||
await synchronizerStart();
|
||||
|
||||
const status = await new ReportService().syncStatus(syncTargetId());
|
||||
expect(status.items.Note).toEqual({ total: 2, synced: 2 });
|
||||
expect(status.conflicted.total).toBe(3);
|
||||
expect(status.total.synced).toBe(status.total.total);
|
||||
});
|
||||
|
||||
it('should move sync errors to the "ignored" section after clicking "ignore"', async () => {
|
||||
const folder = await Folder.save({ title: 'Test' });
|
||||
const noteCount = 5;
|
||||
|
||||
@@ -135,9 +135,10 @@ export default class ReportService {
|
||||
}
|
||||
|
||||
const conflictedCount = await Note.conflictedCount();
|
||||
const syncIneligibleConflictedCount = await Note.syncIneligibleConflictedCount();
|
||||
|
||||
output.total = {
|
||||
total: itemCount - conflictedCount,
|
||||
total: itemCount - syncIneligibleConflictedCount,
|
||||
synced: syncedCount,
|
||||
};
|
||||
|
||||
@@ -146,10 +147,10 @@ export default class ReportService {
|
||||
};
|
||||
|
||||
output.conflicted = {
|
||||
total: await Note.conflictedCount(),
|
||||
total: conflictedCount,
|
||||
};
|
||||
|
||||
output.items['Note'].total -= output.conflicted.total;
|
||||
output.items['Note'].total -= syncIneligibleConflictedCount;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user