summaryrefslogtreecommitdiff
path: root/nodejs/automation/exploration.ts
blob: 9ea0a5baaab4e0123f19b4cef4fc175dca5f1ec8 (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 '../lib/types.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 {} }))();
}