mirror of
https://github.com/aljazceru/hypergolic.git
synced 2025-12-22 15:54:24 +01:00
problem: incorrect reference time calculation
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
import { Separator } from '$lib/components/ui/separator/index.js';
|
import { Separator } from '$lib/components/ui/separator/index.js';
|
||||||
import * as Table from '@/components/ui/table';
|
import * as Table from '@/components/ui/table';
|
||||||
import { Rocket, RocketATagFilter } from '@/event_helpers/rockets';
|
import { Rocket, RocketATagFilter } from '@/event_helpers/rockets';
|
||||||
import { getCuckPrice, getRocketURL, unixToRelativeTime } from '@/helpers';
|
import { formatReferenceTime, getCuckPrice, getRocketURL, unixToRelativeTime } from '@/helpers';
|
||||||
import { derived } from 'svelte/store';
|
import { derived } from 'svelte/store';
|
||||||
|
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
@@ -51,6 +51,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: referenceTime = cuckPrice
|
||||||
|
? formatReferenceTime(((merit.Sats / 100000000) * cuckPrice) / 70)
|
||||||
|
: '...';
|
||||||
|
|
||||||
let votes = derived(_votes, ($_votes) => {
|
let votes = derived(_votes, ($_votes) => {
|
||||||
return new MapOfVotes($_votes, parsedRocket, merit).Votes;
|
return new MapOfVotes($_votes, parsedRocket, merit).Votes;
|
||||||
});
|
});
|
||||||
@@ -156,13 +160,12 @@
|
|||||||
<div class="font-semibold">Analysis</div>
|
<div class="font-semibold">Analysis</div>
|
||||||
<span class="grid gap-0.5 not-italic text-muted-foreground">
|
<span class="grid gap-0.5 not-italic text-muted-foreground">
|
||||||
A competent freelance developer earns $70 CuckLoserBucks an hour (on average). Using
|
A competent freelance developer earns $70 CuckLoserBucks an hour (on average). Using
|
||||||
this rate, the contributor is claiming to have spent about {merit.Sats / 1000} hours working
|
this rate, the contributor is claiming to have spent about {referenceTime} working on this.
|
||||||
on this.
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid auto-rows-max gap-3">
|
<div class="grid auto-rows-max gap-3">
|
||||||
<div class="font-semibold">Reference Time</div>
|
<div class="font-semibold">Reference Time</div>
|
||||||
<div class="text-muted-foreground">{merit.Sats / 1000} hours</div>
|
<div class="text-muted-foreground">{referenceTime}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Separator class="my-4" />
|
<Separator class="my-4" />
|
||||||
|
|||||||
@@ -57,6 +57,25 @@ export function unixToRelativeTime(timestamp: number): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatReferenceTime(hours: number) {
|
||||||
|
const totalMinutes = Math.round(hours * 60);
|
||||||
|
const wholeHours = Math.floor(totalMinutes / 60);
|
||||||
|
const remainingMinutes = totalMinutes % 60;
|
||||||
|
|
||||||
|
let result = '';
|
||||||
|
|
||||||
|
if (wholeHours > 0) {
|
||||||
|
result += `${wholeHours} hour${wholeHours > 1 ? 's' : ''}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remainingMinutes > 0) {
|
||||||
|
if (result.length > 0) result += ' and ';
|
||||||
|
result += `${remainingMinutes} minute${remainingMinutes > 1 ? 's' : ''}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result || '0 minutes';
|
||||||
|
}
|
||||||
|
|
||||||
export async function getCuckPrice(): Promise<number | Error> {
|
export async function getCuckPrice(): Promise<number | Error> {
|
||||||
try {
|
try {
|
||||||
var url = 'https://api.coindesk.com/v1/bpi/currentprice.json';
|
var url = 'https://api.coindesk.com/v1/bpi/currentprice.json';
|
||||||
|
|||||||
Reference in New Issue
Block a user