mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
better sync implementation of ping job
This commit is contained in:
parent
1b900bb907
commit
1ebf9d4e56
@ -1,17 +1,12 @@
|
|||||||
const sql = require('./sql');
|
const sql = require('./sql');
|
||||||
const utils = require('./utils');
|
|
||||||
const messaging = require('./messaging');
|
const messaging = require('./messaging');
|
||||||
const options = require('./options');
|
const options = require('./options');
|
||||||
const sync_setup = require('./sync_setup');
|
const sync_setup = require('./sync_setup');
|
||||||
|
|
||||||
let startTime = utils.nowDate();
|
let lastSentSyncId;
|
||||||
let sentSyncId = [];
|
|
||||||
|
|
||||||
async function sendPing() {
|
async function sendPing() {
|
||||||
const syncs = await sql.getResults("SELECT * FROM sync WHERE sync_date >= ?", [startTime]);
|
const syncData = await sql.getResults("SELECT * FROM sync WHERE id > ?", [lastSentSyncId]);
|
||||||
startTime = utils.nowDate();
|
|
||||||
|
|
||||||
const syncData = syncs.filter(sync => !sentSyncId.includes(sync.id));
|
|
||||||
|
|
||||||
const lastSyncedPush = await options.getOption('last_synced_push');
|
const lastSyncedPush = await options.getOption('last_synced_push');
|
||||||
|
|
||||||
@ -23,9 +18,13 @@ async function sendPing() {
|
|||||||
changesToPushCount: sync_setup.isSyncSetup ? changesToPushCount : 0
|
changesToPushCount: sync_setup.isSyncSetup ? changesToPushCount : 0
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const sync of syncData) {
|
if (syncData.length > 0) {
|
||||||
sentSyncId.push(sync.id);
|
lastSentSyncId = syncData[syncData.length - 1].id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sql.dbReady.then(() => setInterval(sendPing, 1000));
|
sql.dbReady.then(async () => {
|
||||||
|
lastSentSyncId = await sql.getSingleValue("SELECT MAX(id) FROM sync");
|
||||||
|
|
||||||
|
setInterval(sendPing, 1000);
|
||||||
|
});
|
@ -280,7 +280,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="sql-console-dialog" title="Event log" style="display: none; padding: 20px;">
|
<div id="sql-console-dialog" title="SQL console" style="display: none; padding: 20px;">
|
||||||
<textarea style="width: 100%; height: 100px" id="sql-console-query"></textarea>
|
<textarea style="width: 100%; height: 100px" id="sql-console-query"></textarea>
|
||||||
<button class="btn btn-danger" id="sql-console-execute">Execute</button>
|
<button class="btn btn-danger" id="sql-console-execute">Execute</button>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user