sync refactorings, added logging for performance tracking

This commit is contained in:
zadam
2020-04-04 14:57:19 +02:00
parent 6201dd70a0
commit ae50c9847d
6 changed files with 127 additions and 81 deletions

View File

@@ -114,14 +114,22 @@ async function forceNoteSync(req) {
}
async function getChanged(req) {
const startTime = Date.now();
const lastSyncId = parseInt(req.query.lastSyncId);
const syncs = await sql.getRows("SELECT * FROM sync WHERE isSynced = 1 AND id > ? LIMIT 1000", [lastSyncId]);
return {
const ret = {
syncs: await syncService.getSyncRecords(syncs),
maxSyncId: await sql.getValue('SELECT MAX(id) FROM sync WHERE isSynced = 1')
};
if (ret.syncs.length > 0) {
log.info(`Returning ${ret.syncs.length} in ${Date.now() - startTime}ms`);
}
return ret;
}
async function update(req) {