-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #405 from rl404/develop
Develop
- Loading branch information
Showing
22 changed files
with
181 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/routes/(app)/statistics/VtuberCountByLanguageChart.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script lang="ts"> | ||
import BarChart from '$lib/components/charts/BarChart.svelte'; | ||
import { getAxiosError } from '$lib/utils/api'; | ||
import axios from 'axios'; | ||
import { Spinner } from 'flowbite-svelte'; | ||
import { onMount } from 'svelte'; | ||
import type { VtuberLanguageCountResponseData } from '../../api/statistics/vtubers/language-count/+server'; | ||
export let limit: number = -1; | ||
let data: VtuberLanguageCountResponseData[]; | ||
let loading: boolean = true; | ||
let error: string = ''; | ||
onMount(() => { | ||
axios | ||
.get(`/api/statistics/vtubers/language-count`) | ||
.then((resp) => (data = resp.data.data.slice(0, limit))) | ||
.catch((err) => (error = getAxiosError(err))) | ||
.finally(() => (loading = false)); | ||
}); | ||
const onClick = (d: any) => | ||
window.open(`/vtubers?language_id=${data[d.detail].id}`, '_blank')?.focus(); | ||
</script> | ||
|
||
{#if loading} | ||
<div class="flex h-full w-full items-center justify-center"> | ||
<Spinner /> | ||
</div> | ||
{:else if error !== ''} | ||
<div class="flex h-full w-full items-center justify-center text-red-500">{error}</div> | ||
{:else} | ||
<BarChart | ||
data={data.map((d) => ({ | ||
name: d.name, | ||
value: d.count | ||
}))} | ||
seriesName="Count" | ||
on:clickArea={onClick} | ||
/> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,6 @@ | |
(1000 * 3600 * 24 * 30 * 12) | ||
}))} | ||
seriesName="Years" | ||
on:click={onClick} | ||
on:clickArea={onClick} | ||
/> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { SHIMAKAZE_HOST } from '$env/static/private'; | ||
import type { RequestHandler } from './$types'; | ||
import type { BaseAPIResponse, MetaAPIResponse } from '../types'; | ||
|
||
export type LanguagesResponse = BaseAPIResponse & { | ||
data: LanguageResponseData[]; | ||
meta: MetaAPIResponse; | ||
}; | ||
|
||
export type LanguageResponseData = { | ||
id: number; | ||
name: string; | ||
}; | ||
|
||
export const GET = (async () => { | ||
const resp = await fetch(`${SHIMAKAZE_HOST}/languages`); | ||
const data = await resp.json(); | ||
return new Response(JSON.stringify(data), { | ||
headers: { | ||
'content-type': 'application/json', | ||
'cache-control': 'max-age=86400, s-maxage=86400, stale-while-revalidate=86400' | ||
}, | ||
status: resp.status | ||
}); | ||
}) satisfies RequestHandler; |
25 changes: 25 additions & 0 deletions
25
src/routes/api/statistics/vtubers/language-count/+server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { RequestHandler } from './$types'; | ||
import { SHIMAKAZE_HOST } from '$env/static/private'; | ||
import type { BaseAPIResponse } from '../../../types'; | ||
|
||
export type VtuberLanguageCountResponse = BaseAPIResponse & { | ||
data: VtuberLanguageCountResponseData[]; | ||
}; | ||
|
||
export type VtuberLanguageCountResponseData = { | ||
id: number; | ||
name: string; | ||
count: number; | ||
}; | ||
|
||
export const GET = (async () => { | ||
const resp = await fetch(`${SHIMAKAZE_HOST}/statistics/vtubers/language-count`); | ||
const data = await resp.json(); | ||
return new Response(JSON.stringify(data), { | ||
headers: { | ||
'content-type': 'application/json', | ||
'cache-control': 'max-age=86400, s-maxage=86400, stale-while-revalidate=86400' | ||
}, | ||
status: resp.status | ||
}); | ||
}) satisfies RequestHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.