From 68c457964a02d290f3fe225b090c549d664bb836 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 1 Jun 2023 01:11:21 +0200 Subject: Another big refactoring --- automation/exploration.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 automation/exploration.js (limited to 'automation/exploration.js') diff --git a/automation/exploration.js b/automation/exploration.js new file mode 100644 index 0000000..9ea5bf8 --- /dev/null +++ b/automation/exploration.js @@ -0,0 +1,20 @@ +import * as db from '../database/systems.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(); +} -- cgit v1.2.3