36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import { getAllStreamsForVtuber, getStreamCountForVtuber } from "@/lib/streams";
|
|
import { getVodsForVtuber } from "@/lib/vods";
|
|
import { IVtuber } from "@/lib/vtubers";
|
|
|
|
export interface IArchiveProgressProps {
|
|
vtuber: IVtuber;
|
|
}
|
|
|
|
export default async function ArchiveProgress ({ vtuber }: IArchiveProgressProps) {
|
|
|
|
// // Check if totalStreams is not zero before calculating completedPercentage
|
|
// const completedPercentage = (totalStreams !== 0) ? Math.round(eligibleStreams / totalStreams * 100) : 0;
|
|
const goodStreams = await getStreamCountForVtuber(vtuber.id, ['good'])
|
|
const issueStreams = await getStreamCountForVtuber(vtuber.id, ['issue'])
|
|
const totalStreams = await getStreamCountForVtuber(vtuber.id)
|
|
const eligibleStreams = goodStreams+issueStreams
|
|
const completedPercentage = (eligibleStreams / totalStreams) * 100
|
|
return (
|
|
<div>
|
|
{/* <p>
|
|
{totalStreams} known streams<br />
|
|
{goodStreams} streams archived<br />
|
|
{issueStreams} streams with issues<br />
|
|
</p> */}
|
|
<p className="heading">{eligibleStreams}/{totalStreams} Streams Archived ({completedPercentage}%)</p>
|
|
<progress className="progress is-success" value={eligibleStreams} max={totalStreams}>{completedPercentage}%</progress>
|
|
</div>
|
|
)
|
|
// @todo
|
|
|
|
// return (
|
|
// <div>
|
|
// <i><p className="">{(vods) ? vods.data.length : 0} vods</p></i>
|
|
// </div>
|
|
// )
|
|
} |