Files
bee-dashboard/utils/update-map-data.js
Bálint Ujvári 519c411db0 feat: sync and update with all changes from fork (#720)
* feat: sync and update with all changes from fork
* refactor: extract clipboard copy logic into custom hook
* fix: correct spelling of DEFAULT_REFRESH_FREQUENCY_MS in Stamps and WalletBalance providers
* refactor(ui-tests): replace fixed sleeps with condition-based waits
* fix: handle null values for size and granteeCount in infoGroups
* fix(lint): add newline at end of file in useClipboardCopy hook
* fix(ui-tests): page.goto URL
* refactor: update import paths for useClipboardCopy

---------

Co-authored-by: Ferenc Sárai <sarai.ferenc@gmail.com>
2026-03-02 11:34:39 +01:00

59 lines
1.4 KiB
JavaScript
Executable File

#!/usr/bin/env node
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable no-console */
const axios = require('axios')
const fs = require('fs')
const getMapJSON = require('dotted-map').getMapJSON
const DATA_SOURCE = 'https://swarmscan-api.resenje.org/v1/network/dump'
const DATA_DESTINATION = './src/assets/data/nodes-db.json'
const MAP_HEIGHT = 50
const MAP_DESTINATION = './src/assets/data/map-data.json'
async function getData(url) {
const res = await axios.get(url)
return res.data
}
function processData(data) {
const db = new Map()
data.nodes.forEach(node => {
if (node.location) {
db.set(node.overlay, { lat: node.location.latitude, lng: node.location.longitude })
}
})
return Object.fromEntries([...db.entries()].sort())
}
function saveFile(db, path) {
return fs.writeFileSync(path, JSON.stringify(db, null, 2))
}
function preComputeMap() {
return getMapJSON({ height: MAP_HEIGHT, grid: 'diagonal' })
}
async function main() {
console.log('Fetching DB data')
const dataDump = await getData(DATA_SOURCE)
console.log('Processing DB data')
const db = processData(dataDump)
console.log('Saving DB data')
saveFile(db, DATA_DESTINATION)
console.log('Pre-computing the word map')
const map = preComputeMap()
console.log('Saving map data')
saveFile(map, MAP_DESTINATION)
console.log('Done')
}
main()