Add Stats
This commit is contained in:
parent
166ca1fe5f
commit
1d138b629d
@ -1,47 +1,88 @@
|
||||
<script>
|
||||
import Header from '$lib/navigation/header.svelte'
|
||||
import Loading from '$lib/navigation/loading.svelte';
|
||||
import Island from '$lib/islands/island.svelte';
|
||||
import Header from '$lib/navigation/header.svelte'
|
||||
import Loading from '$lib/navigation/loading.svelte';
|
||||
import Nav from '$lib/navigation/nav.svelte'
|
||||
import { onMount } from 'svelte';
|
||||
const title = "Statistics"
|
||||
let isLoading = true;
|
||||
|
||||
let update_timetable = "", update_corpus="",
|
||||
update_pis = "", count_ldbws_api="",
|
||||
count_ldbsvws_api = "", count_corpus_api = "",
|
||||
count_timetable_db = "", count_pis_db = "",
|
||||
count_corpus_db = "", count_stations_db = "",
|
||||
length_users = "", length_registrations = "",
|
||||
length_stations = "", length_corpus = "",
|
||||
length_pis = "", length_timetable = ""
|
||||
let data, error;
|
||||
|
||||
onMount(async () => {
|
||||
const url = "https://owlboard.info/misc/server/stats"
|
||||
const res = await fetch(url);
|
||||
if (res.status == 200) {
|
||||
data = await res.json();
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
isLoading = false;
|
||||
})
|
||||
|
||||
function U2L(input) {
|
||||
try {
|
||||
const datetime = new Date(input*1000)
|
||||
return datetime.toLocaleString()
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<Header {title} />
|
||||
|
||||
{#if isLoading}
|
||||
<Loading />
|
||||
{:else}
|
||||
<h2>Last Update</h2>
|
||||
<p>Timetable Data: <span>{update_timetable}</span></p>
|
||||
<p>Location Reference Data: <span>{update_corpus}</span></p>
|
||||
<p>PIS Codes Data: <span>{update_pis}</span></p>
|
||||
|
||||
<h2>Request Counts</h2>
|
||||
<p>LDBWS API: <span>{count_ldbws_api}</span></p>
|
||||
<p>LDBSVWS API: <span>{count_ldbsvws_api}</span></p>
|
||||
<p>Location Reference API: <span>{count_corpus_api}</span></p>
|
||||
<p>Timetable: <span>{count_timetable_db}</span></p>
|
||||
<p>PIS: <span>{count_pis_db}</span></p>
|
||||
<p>Location Reference: <span>{count_corpus_db}</span></p>
|
||||
<p>Stations: <span>{count_stations_db}</span></p>
|
||||
|
||||
<h2>Database Lengths</h2>
|
||||
<p>Users: <span>{length_users}</span></p>
|
||||
<p>Pending Registrations: <span>{length_registrations}</span></p>
|
||||
<p>CORPUS: <span>{length_corpus}</span></p>
|
||||
<p>Stations: <span>{length_stations}</span></p>
|
||||
<p>PIS: <span>{length_pis}</span></p>
|
||||
<p>Timetable: <span>{length_timetable}</span></p>
|
||||
{#if error}
|
||||
<Island>
|
||||
<p>Unable to connect to server</p>
|
||||
</Island>
|
||||
{/if}
|
||||
|
||||
<Nav />
|
||||
{#if isLoading}
|
||||
<Loading />
|
||||
{:else if !isLoading && !error}
|
||||
<p>API Server:<br><span>{data?.hostname}</span></p>
|
||||
<p>Runtime Mode: <span>{data?.runtimeMode}</span></p>
|
||||
<p>Stats Reset: <span>{U2L(data?.reset) || 'Unknown'}</span></p>
|
||||
<h2>Last Update</h2>
|
||||
<p>Timetable: <span>{U2L(data?.updateTimes?.timetable)}</span></p>
|
||||
<p>Location Ref: <span>{U2L(data?.updateTimes?.corpus)}</span></p>
|
||||
<p>PIS Codes: <span>{U2L(data?.updateTimes?.pis)}</span></p>
|
||||
<p>Reason Codes: <span>{U2L(data?.updateTimes?.reasonCodes)}</span></p>
|
||||
|
||||
<h2>Request Counts</h2>
|
||||
<p>LDBWS API: <span>{data?.requestCounts?.ldbws_api}</span></p>
|
||||
<p>LDBSVWS API: <span>{data?.requestCounts?.lsbsvws_api}</span></p>
|
||||
<p>Location Reference API: <span>{data?.requestCounts?.corpus_api}</span></p>
|
||||
<p>Timetable: <span>{data?.requestCounts?.timetable_db}</span></p>
|
||||
<p>PIS: <span>{data?.requestCounts?.pis_db}</span></p>
|
||||
<p>Location Reference: <span>{data?.requestCounts?.corpus_db}</span></p>
|
||||
<p>Stations: <span>{data?.requestCounts?.stations_db}</span></p>
|
||||
|
||||
<h2>Database Lengths</h2>
|
||||
<p>Users: <span>{data?.dbLengths?.users}</span></p>
|
||||
<p>Pending Registrations: <span>{data?.dbLengths?.registrations}</span></p>
|
||||
<p>CORPUS: <span>{data?.dbLengths?.corpus}</span></p>
|
||||
<p>Stations: <span>{data?.dbLengths?.stations}</span></p>
|
||||
<p>PIS: <span>{data?.dbLengths?.pis}</span></p>
|
||||
<p>Timetable: <span>{data?.dbLengths?.timetable}</span></p>
|
||||
<p>Reason Codes: <span>{data?.dbLengths?.reasonCodes}</span></p>
|
||||
{/if}
|
||||
|
||||
<Nav />
|
||||
|
||||
<style>
|
||||
span {
|
||||
color: white;
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
color: lightgray;
|
||||
}
|
||||
h2 {
|
||||
margin-bottom: 2px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user