Skip to content

Commit

Permalink
fix horrifying time complexity that would make dijkstra cry
Browse files Browse the repository at this point in the history
  • Loading branch information
TraceLD committed Feb 12, 2021
1 parent 0e1b0bd commit 37cc55d
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/Mmcc.Stats.Frontend/src/dashboard/WeeklyTrendsItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
export let pingsWeeklyAvgs: PingsWeeklyAvgs;
export let tpsWeeklyAvgs: TpsWeeklyAvgs;
let differenceString = getDifferenceString(thisAvg.avg, getCorrespondingLastWeek(thisAvg));
let tpsString = getCorrespondingTpsString(thisAvg);
function getDifferenceString(thisWeek: number, lastWeek: number): string {
if (lastWeek === 0) return "+100%";
const v: number = ((thisWeek - lastWeek) / lastWeek) * 100;
Expand Down Expand Up @@ -54,29 +57,20 @@
</p>
</div>
<div
class:bg-green-500={getDifferenceString(
thisAvg.avg,
getCorrespondingLastWeek(thisAvg)
).startsWith("+")}
class:bg-red-500={getDifferenceString(
thisAvg.avg,
getCorrespondingLastWeek(thisAvg)
).startsWith("-")}
class:bg-green-500={differenceString.startsWith("+")}
class:bg-red-500={differenceString.startsWith("-")}
class="rounded text-sm px-2 py-1 ml-3 w-28 md:w-48 text-center"
>
<span class="font-bold"
>{getDifferenceString(
thisAvg.avg,
getCorrespondingLastWeek(thisAvg)
)}</span
>{differenceString}</span
>
<span class="font-light hidden md:inline-block">vs last week</span>
</div>
</div>
<div class="border-l border-gray-500 h-8 w-1 mr-3 ml-4" />
<div>
<p class="text-3xl mb-0">
{getCorrespondingTpsString(thisAvg)}
{tpsString}
</p>
<p class="font-light text-xs text-gray-500 -mt-1">
avg tps
Expand Down

0 comments on commit 37cc55d

Please sign in to comment.