1
0
Fork 0

Moved the nodejs agent to its own subfolder to make room for my haskell agent

This commit is contained in:
Julien Dessaux 2023-07-01 23:13:13 +02:00
parent 0bc0df0891
commit 36cc33f9e9
Signed by: adyxax
GPG key ID: F92E51B86E07177E
22 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,21 @@
import * as db from '../database/systems.js';
import * as api from '../lib/api.js';
// Retrieves all systems information, should be called only once after registering
export async function init() {
if (db.isInit()) {
return;
}
for (let page=1; true; ++page) {
const response = await api.send({endpoint: `/systems?limit=20&page=${page}`, priority:100});
if (response.error !== undefined) {
throw response;
}
response.data.forEach(system => db.setSystem(system));
if (response.meta.total <= response.meta.limit * page) {
break;
}
}
console.log('Finished retrieving all systems information');
db.init();
}