summaryrefslogtreecommitdiff
path: root/automation/exploration.js
blob: 9ea5bf8e55be2bdce2924c758e6072d098411240 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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();
}