Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This is a Web app that aggregates the various known [BMLT Root Servers](https://bmlt.app/setting-up-the-bmlt/), and creates a "live" table that displays some basic statistics about those servers.

The tally queries the Aggregator for its results. Virtual servers are not catalogued in the Aggregator, so they are pulled from [here](src/lib/VirtualRoots.ts).
The tally queries the Aggregator for its results.

## [It can be seen in action here.](https://tally.bmlt.app)

Expand Down
525 changes: 268 additions & 257 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@
"validate": "prettier --write . && prettier --check . && eslint . && svelte-kit sync && svelte-check --tsconfig ./tsconfig.json"
},
"devDependencies": {
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/kit": "^2.5.27",
"@sveltejs/adapter-static": "^3.0.10",
"@sveltejs/kit": "^2.57.1",
"@sveltejs/vite-plugin-svelte": "^7.0.0",
"@types/eslint": "9.6.1",
"@types/google.maps": "^3.55.9",
"eslint": "^10.1.0",
"eslint-config-prettier": "^10.0.0",
"eslint-plugin-svelte": "^3.0.0",
"gh-pages": "^6.1.1",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.2.6",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"tslib": "^2.4.1",
"typescript": "^5.5.0",
"typescript-eslint": "^8.15.0",
"vite": "^8.0.1"
"@types/google.maps": "^3.58.1",
"eslint": "^10.2.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-svelte": "^3.17.0",
"gh-pages": "^6.3.0",
"prettier": "^3.8.2",
"prettier-plugin-svelte": "^3.5.1",
"svelte": "^5.55.3",
"svelte-check": "^4.4.6",
"tslib": "^2.8.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.58.1",
"vite": "^8.0.8"
},
"type": "module",
"dependencies": {
"@eslint/js": "^10.0.1",
"@googlemaps/adv-markers-utils": "^1.2.4",
"@googlemaps/js-api-loader": "^2.0.1"
"@googlemaps/js-api-loader": "^2.0.2"
}
}
19 changes: 0 additions & 19 deletions src/lib/VirtualRoots.ts

This file was deleted.

71 changes: 4 additions & 67 deletions src/lib/services.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { tallyData, meetingData, currentView, isLoadingData } from './store';
import { VirtualRoots } from '$lib/VirtualRoots';
import type { Tally, AggregatorRoot, Root, Reports, ServerInfo, ServiceBody, Meeting, MeetingLocations } from '$lib/types';
import type { Tally, AggregatorRoot, Root, Reports, MeetingLocations } from '$lib/types';

const aggregatorUrl: string = 'https://aggregator.bmltenabled.org/main_server';
const concurrentRequests = 4;

export const fetchTallyData = async () => {
try {
const aggregatorRootData: AggregatorRoot[] = await getJSON(`${aggregatorUrl}/api/v1/rootservers/`);
const newState = await calculateTallyData(aggregatorRootData);
const newState = calculateTallyData(aggregatorRootData);

tallyData.update((state) => ({
...state,
Expand Down Expand Up @@ -64,55 +63,7 @@ export const displayTallyMap = () => {
currentView.set('map');
};

const getVirtualRootsDetails = async (roots: Root[]): Promise<Root[]> => {
const updatedRoots: Root[] = [];

for (const root of roots) {
try {
const serviceBodies: ServiceBody[] = await getJSON(`${root.root_server_url}client_interface/json/?switcher=GetServiceBodies`);

const counts = serviceBodies.reduce(
(acc, serviceBody) => {
if (serviceBody.type === 'ZF') {
acc.zones++;
} else if (serviceBody.type === 'RS') {
acc.regions++;
} else {
acc.areas++;
}
return acc;
},
{ regions: 0, areas: 0, zones: 0 }
);

const serverInfo: ServerInfo[] = await getJSON(`${root.root_server_url}client_interface/json/?switcher=GetServerInfo`);
const meetings: Meeting[] = await getJSON(`${root.root_server_url}client_interface/json/?switcher=GetSearchResults&data_field_key=id_bigint,meeting_name`);

const virtualGroupDistinction: Set<string> = new Set(meetings.map((meeting) => meeting.meeting_name));

updatedRoots.push({
root_server_url: root.root_server_url,
name: root.name,
num_zones: counts.zones,
num_regions: counts.regions,
num_areas: counts.areas,
num_groups: virtualGroupDistinction.size,
num_total_meetings: meetings.length,
num_in_person: root.num_in_person,
num_virtual: root.num_virtual,
num_hybrid: root.num_hybrid,
num_unknown: root.num_unknown,
server_info: JSON.stringify(serverInfo[0])
});
} catch (error) {
console.error(`Error fetching data for root ${root.id}:`, error);
}
}

return updatedRoots;
};

const calculateTallyData = async (roots: AggregatorRoot[]): Promise<Partial<Tally>> => {
const calculateTallyData = (roots: AggregatorRoot[]): Partial<Tally> => {
let meetingsCount = 0;
let groupsCount = 0;
let areasCount = 0;
Expand Down Expand Up @@ -149,27 +100,13 @@ const calculateTallyData = async (roots: AggregatorRoot[]): Promise<Partial<Tall
});
});

const virtualRoots = await getVirtualRootsDetails(VirtualRoots);

virtualRoots.forEach((virtualRoot) => {
virtualRoot.root_server_url = virtualRoot.root_server_url.replace(/\/$/, '');
const version = JSON.parse(virtualRoot.server_info).version;
byRootServerVersions[version] = (byRootServerVersions[version] || 0) + 1;
meetingsCount += virtualRoot.num_total_meetings;
groupsCount += virtualRoot.num_groups;
areasCount += virtualRoot.num_areas;
regionsCount += virtualRoot.num_regions;
zonesCount += virtualRoot.num_zones;
});

filteredRoots.push(...virtualRoots);
return {
meetingsCount,
groupsCount,
areasCount,
regionsCount,
zonesCount,
serversCount: roots.length + virtualRoots.length,
serversCount: roots.length,
filteredRoots,
roots,
serviceBodiesCount: areasCount + regionsCount + zonesCount,
Expand Down
1 change: 0 additions & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export interface Root {
num_hybrid: number;
num_unknown: number;
server_info: string;
id?: string;
}

export interface AggregatorRoot {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
"moduleResolution": "bundler",
"types": ["node", "google.maps"]
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
Expand Down