import { getAllStreamsForVtuber, getStreamCountForVtuber } from "@/app/lib/streams";
import { getVodsForVtuber } from "@/app/lib/vods";
import { IVtuber } from "@futureporn/types";

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 = Math.floor((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>
    // )
}