|
@@ -8,11 +8,6 @@ async function getROI(cx: string) {
|
|
|
return {lastModified, profits};
|
|
return {lastModified, profits};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const buildingsPromise = fetch('https://api.prunplanner.org/data/buildings/')
|
|
|
|
|
- .then((r) => r.json()).then((buildings: Building[]) =>
|
|
|
|
|
- buildings.filter((b) => b.building_type === 'PRODUCTION')
|
|
|
|
|
- .sort((a, b) => a.building_ticker.localeCompare(b.building_ticker)));
|
|
|
|
|
-
|
|
|
|
|
const lowVolume = document.querySelector('input#low-volume') as HTMLInputElement;
|
|
const lowVolume = document.querySelector('input#low-volume') as HTMLInputElement;
|
|
|
|
|
|
|
|
const cxSelect = document.querySelector('select#cx') as HTMLSelectElement;
|
|
const cxSelect = document.querySelector('select#cx') as HTMLSelectElement;
|
|
@@ -44,15 +39,24 @@ async function render() {
|
|
|
const tbody = document.querySelector('tbody')!;
|
|
const tbody = document.querySelector('tbody')!;
|
|
|
tbody.innerHTML = '';
|
|
tbody.innerHTML = '';
|
|
|
|
|
|
|
|
|
|
+ const cx = cxSelect.value;
|
|
|
|
|
+ if (!roiCache[cx])
|
|
|
|
|
+ roiCache[cx] = getROI(cx);
|
|
|
|
|
+ const {lastModified, profits} = await roiCache[cx];
|
|
|
|
|
+
|
|
|
|
|
+ const buildingTickers = new Set(profits.map(p => p.building));
|
|
|
|
|
+ const buildings: {ticker: string, expertise: keyof typeof expertise}[] = Array.from(buildingTickers)
|
|
|
|
|
+ .map((building) => ({ticker: building, expertise: profits.find(p => p.building === building)!.expertise}))
|
|
|
|
|
+ .sort((a, b) => a.ticker.localeCompare(b.ticker));
|
|
|
let selectedBuilding = buildingSelect.value;
|
|
let selectedBuilding = buildingSelect.value;
|
|
|
let buildingFound = false;
|
|
let buildingFound = false;
|
|
|
buildingSelect.innerHTML = '<option value="">(all)</option>';
|
|
buildingSelect.innerHTML = '<option value="">(all)</option>';
|
|
|
- for (const building of await buildingsPromise)
|
|
|
|
|
|
|
+ for (const building of buildings)
|
|
|
if (expertiseSelect.value === '' || expertiseSelect.value === building.expertise) {
|
|
if (expertiseSelect.value === '' || expertiseSelect.value === building.expertise) {
|
|
|
const option = document.createElement('option');
|
|
const option = document.createElement('option');
|
|
|
- option.value = building.building_ticker;
|
|
|
|
|
- option.textContent = building.building_ticker;
|
|
|
|
|
- if (building.building_ticker === selectedBuilding) {
|
|
|
|
|
|
|
+ option.value = building.ticker;
|
|
|
|
|
+ option.textContent = building.ticker;
|
|
|
|
|
+ if (building.ticker === selectedBuilding) {
|
|
|
buildingFound = true;
|
|
buildingFound = true;
|
|
|
option.selected = true;
|
|
option.selected = true;
|
|
|
}
|
|
}
|
|
@@ -61,11 +65,6 @@ async function render() {
|
|
|
if (!buildingFound)
|
|
if (!buildingFound)
|
|
|
selectedBuilding = '';
|
|
selectedBuilding = '';
|
|
|
|
|
|
|
|
- const cx = cxSelect.value;
|
|
|
|
|
- if (!roiCache[cx])
|
|
|
|
|
- roiCache[cx] = getROI(cx);
|
|
|
|
|
- const {lastModified, profits} = await roiCache[cx];
|
|
|
|
|
-
|
|
|
|
|
for (const p of profits) {
|
|
for (const p of profits) {
|
|
|
const volumeRatio = p.output_per_day / p.average_traded_7d;
|
|
const volumeRatio = p.output_per_day / p.average_traded_7d;
|
|
|
if (!lowVolume.checked && volumeRatio > 0.05)
|
|
if (!lowVolume.checked && volumeRatio > 0.05)
|