Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: changed hours to minutes #696

Merged
merged 1 commit into from
Sep 11, 2023
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
18 changes: 9 additions & 9 deletions src/lib/components/Global/DrawerMain.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
} from '$lib/stores/remoteConfigStore'
import IconMageText from '$lib/assets/icons/IconMageText.svelte'
import { is_apps_modal_open, is_login_modal_open } from '$lib/stores/helperStore'
import { colorFromLevel, levelAndBarValueFromExp } from '$lib/utils'
import { colorFromLevel, getNumberInThousands, levelAndBarValueFromExp } from '$lib/utils'
import { onMount } from 'svelte'
import { isOnline } from '$lib/stores/userStore'
import { get } from '$lib/api'
Expand All @@ -40,7 +40,7 @@
let progressBarValue = 0
let progressBarColor = colorFromLevel(1)
let streakCount: any = { current: 0, highest: 0 }
let hoursStreamed: number = 0
let minsStreamed: number = 0
let followers: number = 0
onMount(async () => {
if (currentUser) {
Expand All @@ -50,9 +50,7 @@
progressBarValue = levelAndBarValue.barValue
progressBarColor = colorFromLevel(progressBarLevel)
streakCount = await get(`stats/stream/streak?userId=${$page.data.user?.userId}`)
hoursStreamed = await get(
`stats/stream/total-hours/24-hours?userId=${$page.data.user?.userId}`
)
minsStreamed = await get(`stats/stream/total-mins/24-hours?userId=${$page.data.user?.userId}`)
followers = await get(`follows/count?source=${$page.data.user?.userId}&sourceType=source1`, {
userId: $page.data.user?.userId,
token: $page.data.user?.token
Expand Down Expand Up @@ -124,16 +122,18 @@
</div>
<div
class="flex gap-1 tooltip tooltip-primary"
data-tip="{hoursStreamed} hours streamed today">
data-tip="{getNumberInThousands(minsStreamed || 0)} mins streamed today">
<IconDrawerStreamDuration />
<p class="text-start">
{hoursStreamed} h
{getNumberInThousands(minsStreamed || 0)} m
</p>
</div>
<div class="flex gap-1 tooltip tooltip-primary" data-tip="{followers} followers">
<div
class="flex gap-1 tooltip tooltip-primary"
data-tip="{getNumberInThousands(followers || 0)} followers">
<IconFollowers />
<p class="text-start">
{followers}
{getNumberInThousands(followers || 0)}
</p>
</div>
</div>
Expand Down
18 changes: 9 additions & 9 deletions src/lib/components/Profile/Elements/Stats.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
viewsMonthlyIncr: any,
highestAndCurrentStreak: any,
streakMonthlyIncr: any,
totalHours: any,
totalHoursMonthlyIncr: any,
avgHours: any
totalMins: any,
totalMinsMonthlyIncr: any,
avgMins: any

onMount(async () => {
if (profile) {
viewsMonthlyIncr = (await viewsMonthlyIncr) || 0
highestAndCurrentStreak = (await highestAndCurrentStreak) || 0
streakMonthlyIncr = (await streakMonthlyIncr) || 0
totalHours = (await totalHours) || 0
totalHoursMonthlyIncr = (await totalHoursMonthlyIncr) || 0
avgHours = (await avgHours) || 0
totalMins = (await totalMins) || 0
totalMinsMonthlyIncr = (await totalMinsMonthlyIncr) || 0
avgMins = (await avgMins) || 0
}
})
</script>
Expand Down Expand Up @@ -57,9 +57,9 @@
<div class="stat-figure text-secondary">
<IconProfileStreamDuration />
</div>
<div class="stat-title">Total / Avg Hours</div>
<div class="stat-value text-secondary">{totalHours} / {avgHours}</div>
<div class="stat-desc">{totalHoursMonthlyIncr.monthlyChange} % more than last month</div>
<div class="stat-title">Total / Avg Mins</div>
<div class="stat-value text-secondary">{totalMins} / {avgMins}</div>
<div class="stat-desc">{totalMinsMonthlyIncr.monthlyChange} % more than last month</div>
</div>

<!-- <div class="stat">
Expand Down
12 changes: 6 additions & 6 deletions src/lib/components/Profile/TabSection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
totalChannelViews4Weeks: any,
viewsMonthlyIncr: any,
highestAndCurrentStreak: any,
totalHours: any,
totalMins: any,
streakMonthlyIncr: any,
totalHoursMonthlyIncr: any,
avgHours: any
totalMinsMonthlyIncr: any,
avgMins: any

let tabs: string[] = []
let activeTab = 0
Expand Down Expand Up @@ -52,14 +52,14 @@
<div class="grid h-full" class:hidden={activeTab != tabs.indexOf('Stats')}>
<Stats
{profile}
{avgHours}
{avgMins}
{viewsMonthlyIncr}
{streakMonthlyIncr}
{totalHoursMonthlyIncr}
{totalMinsMonthlyIncr}
{totalChannelViews}
{totalChannelViews4Weeks}
{highestAndCurrentStreak}
{totalHours} />
{totalMins} />
</div>
{/if}
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/routes/[username]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export const load = (async ({ params }: { params: any }) => {
viewsMonthlyIncr: get(`stats/views/monthly-increase?viewType=channel&userId=${profile._id}`),
highestAndCurrentStreak: get(`stats/stream/streak?userId=${profile._id}`),
streakMonthlyIncr: get(`stats/stream/streak/monthly-increase?userId=${profile._id}`),
totalHours: get(`stats/stream/total-hours?userId=${profile._id}`),
totalHoursMonthlyIncr: get(`stats/stream/total-hours/monthly-increase?userId=${profile._id}`),
avgHours: get(`stats/stream/avg-hours?userId=${profile._id}`),
avgHoursMonthlyIncr: get(`stats/stream/avg-hours/monthly-increase?userId=${profile._id}`)
totalMins: get(`stats/stream/total-mins?userId=${profile._id}`),
totalMinsMonthlyIncr: get(`stats/stream/total-mins/monthly-increase?userId=${profile._id}`),
avgMins: get(`stats/stream/avg-mins?userId=${profile._id}`),
avgMinsMonthlyIncr: get(`stats/stream/avg-mins/monthly-increase?userId=${profile._id}`)
}
}
}) satisfies PageServerLoad
Expand Down
6 changes: 3 additions & 3 deletions src/routes/[username]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
viewsMonthlyIncr={data.lazy.viewsMonthlyIncr}
highestAndCurrentStreak={data.lazy.highestAndCurrentStreak}
streakMonthlyIncr={data.lazy.streakMonthlyIncr}
totalHours={data.lazy.totalHours}
totalHoursMonthlyIncr={data.lazy.totalHoursMonthlyIncr}
avgHours={data.lazy.avgHours} />
totalMins={data.lazy.totalMins}
totalMinsMonthlyIncr={data.lazy.totalMinsMonthlyIncr}
avgMins={data.lazy.avgMins} />
</div>
</div>
</div>
Expand Down