summaryrefslogtreecommitdiff
path: root/nodejs/automation/exploration.ts
blob: 67fbfe4acf26a91a0284e4db059ef158c67f57b7 (plain)
1
2
3
4
5
6
7
8
9
import db from '../database/db.ts';
import * as dbSystems from '../database/systems.ts';
import { System } from '../model/system.ts';
import * as api from '../lib/api.ts';

export async function init(): Promise<void> {
	const response = await api.sendPaginated<System>({endpoint: `/systems`, page: Math.max(1, Math.floor(dbSystems.getSystemsCount()/20)), priority: 100});
	db.transaction(() => response.forEach(function(system) { try { dbSystems.addSystem(system); } catch {} }))();
}