Skip to content

Commit

Permalink
Merge pull request #714 from CodeCrowCorp/dev
Browse files Browse the repository at this point in the history
Fix: renamed stats to analytics
  • Loading branch information
gagansuie authored Sep 18, 2023
2 parents 08451c2 + 8b881b9 commit 940b933
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/lib/components/Channel/Stream/VideoItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
if (timerInterval) toggleTimer(false)
if (streamId) {
await patch(
`stats/stream/end?streamId=${streamId}`,
`analytics/stream/end?streamId=${streamId}`,
{},
{
userId: $page.data.user?.userId,
Expand All @@ -331,7 +331,7 @@
if (timerInterval) toggleTimer(false)
if (streamId) {
await patch(
`stats/stream/end?streamId=${streamId}`,
`analytics/stream/end?streamId=${streamId}`,
{},
{
userId: $page.data.user?.userId,
Expand Down Expand Up @@ -417,7 +417,7 @@
streamId = video.screen?.streamId || video.obs?.streamId
if (!streamId) return
if (streamId && streamTime === 0) {
const streamRecord = await get(`stats/stream?streamId=${streamId}`)
const streamRecord = await get(`analytics/stream?streamId=${streamId}`)
streamTime = streamRecord ? (Date.now() - streamRecord.start) / 1000 : 0
}
streamTime = Math.floor(streamTime) + 1
Expand All @@ -430,7 +430,7 @@
//NOTE: check if mine and has been 5 seconds
if (video._id === $page.data.user?.userId && streamTime % 5 == 0) {
await patch(
`stats/stream?streamId=${streamId}`,
`analytics/stream?streamId=${streamId}`,
{},
{
userId: $page.data.user?.userId,
Expand Down
6 changes: 4 additions & 2 deletions src/lib/components/Global/DrawerMain.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
progressBarLevel = levelAndBarValue.level
progressBarValue = levelAndBarValue.barValue
progressBarColor = colorFromLevel(progressBarLevel)
streakCount = await get(`stats/stream/streak?userId=${$page.data.user?.userId}`)
minsStreamed = await get(`stats/stream/total-mins/24-hours?userId=${$page.data.user?.userId}`)
streakCount = await get(`analytics/stream/streak?userId=${$page.data.user?.userId}`)
minsStreamed = await get(
`analytics/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
2 changes: 1 addition & 1 deletion src/lib/components/Profile/Elements/Stats.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<div class="stat-figure text-secondary">
<IconProfileStreamDuration />
</div>
<div class="stat-title">Total / Avg Mins</div>
<div class="stat-title">Total / Avg Mins Streamed</div>
<div class="stat-value text-secondary">{totalMins} / {avgMins}</div>
<div class="stat-desc">{totalMinsMonthlyIncr.monthlyChange} % more than last month</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ export const getSectionUrl = ({
case 'highest-ranked':
return `users/highest-ranked?searchQuery=${query}&skip=${skip}&limit=${limit}`
case 'rising-stars':
//stats/stream/getRisingStars?skip=${0}&limit=${10}
//analytics/stream/getRisingStars?skip=${0}&limit=${10}
//users/rising-stars?searchQuery=${query}&skip=${skip}&limit=${limit}
return `stats/stream/rising-stars?skip=${skip}&limit=${limit}`
return `analytics/stream/rising-stars?skip=${skip}&limit=${limit}`
case 'my':
return `channels/user?searchQuery=${query}&skip=${skip}&limit=${limit}`
case 'fav':
Expand Down
23 changes: 13 additions & 10 deletions src/routes/[username]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ export const load = (async ({ params }: { params: any }) => {
profile: profile,
lazy: {
channels: get(`channels/user?userId=${profile._id}&skip=${0}&limit=${10}`),
totalPageViews: get(`stats/views/total-views?viewType=user&viewId=${profile._id}`),
totalChannelViews: get(`stats/views/total-views?viewType=channel&host=${profile._id}`),
totalPageViews: get(`analytics/views/total-views?viewType=user&viewId=${profile._id}`),
totalChannelViews: get(`analytics/views/total-views?viewType=channel&host=${profile._id}`),
totalChannelViews4Weeks: get(
`stats/views/total-views/4-weeks?viewType=channel&host=${profile._id}`
`analytics/views/total-views/4-weeks?viewType=channel&host=${profile._id}`
),
viewsMonthlyIncr: get(`stats/views/monthly-increase?viewType=channel&host=${profile._id}`),
highestAndCurrentStreak: get(`stats/stream/streak?userId=${profile._id}`),
streakMonthlyIncr: get(`stats/stream/streak/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}`)
viewsMonthlyIncr: get(
`analytics/views/monthly-increase?viewType=channel&host=${profile._id}`
),
highestAndCurrentStreak: get(`analytics/stream/streak?userId=${profile._id}`),
streakMonthlyIncr: get(`analytics/stream/streak/monthly-increase?userId=${profile._id}`),
totalMins: get(`analytics/stream/total-mins?userId=${profile._id}`),
totalMinsMonthlyIncr: get(
`analytics/stream/total-mins/monthly-increase?userId=${profile._id}`
),
avgMins: get(`analytics/stream/avg-mins?userId=${profile._id}`)
}
}
}) satisfies PageServerLoad
Expand Down
2 changes: 1 addition & 1 deletion src/routes/[username]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
onMount(async () => {
if ($page.data.user?.userId !== data.profile._id) {
await post(
`stats/view`,
`analytics/view`,
{
type: 'view',
userId: $page.data.user?.userId,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/channel/[channelId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
await loadMoreChannels()
if ($page.data.user?.userId && channel?.user !== $page.data.user?.userId) {
await post(
`stats/view`,
`analytics/view`,
{
type: 'view',
userId: $page.data.user?.userId,
Expand Down

0 comments on commit 940b933

Please sign in to comment.