fixing frontend image quirks
ci / build (push) Waiting to run Details

This commit is contained in:
CJ_Clippy 2024-06-12 18:54:44 -08:00
parent 71f19065d0
commit 333b4b49aa
15 changed files with 36 additions and 36 deletions

View File

@ -7,25 +7,18 @@ export interface IArchiveProgressProps {
} }
export default async function ArchiveProgress ({ vtuber }: IArchiveProgressProps) { export default async function ArchiveProgress ({ vtuber }: IArchiveProgressProps) {
// const vods = await getVodsForVtuber(vtuber.id)
const streams = await getStreamCountForVtuber(vtuber.id);
// const goodStreams = await getAllStreamsForVtuber(vtuber.id, ['good']);
// const issueStreams = await getAllStreamsForVtuber(vtuber.id, ['issue']);
// const totalStreams = streams.length;
// const eligibleStreams = issueStreams.length+goodStreams.length;
// // Check if totalStreams is not zero before calculating completedPercentage // // Check if totalStreams is not zero before calculating completedPercentage
// const completedPercentage = (totalStreams !== 0) ? Math.round(eligibleStreams / totalStreams * 100) : 0; // const completedPercentage = (totalStreams !== 0) ? Math.round(eligibleStreams / totalStreams * 100) : 0;
const completedPercentage = 50 const totalStreams = await getStreamCountForVtuber(vtuber.id);
const totalStreams = 500 const eligibleStreams = await getStreamCountForVtuber(vtuber.id, ['good', 'issue']);
const eligibleStreams = 50 const completedPercentage = (eligibleStreams / totalStreams) * 100
return ( return (
<div> <div>
<pre> {/* <p>
<code> {totalStreams} known streams<br />
{JSON.stringify(streams, null, 2)} {eligibleStreams} archived<br />
</code> </p> */}
</pre>
<p className="heading">{eligibleStreams}/{totalStreams} Streams Archived ({completedPercentage}%)</p> <p className="heading">{eligibleStreams}/{totalStreams} Streams Archived ({completedPercentage}%)</p>
<progress className="progress is-success" value={eligibleStreams} max={totalStreams}>{completedPercentage}%</progress> <progress className="progress is-success" value={eligibleStreams} max={totalStreams}>{completedPercentage}%</progress>
</div> </div>

View File

@ -1,7 +1,7 @@
import { getCampaign } from "@/lib/patreon"; import { getCampaign } from "@/lib/patreon";
import { getGoals, IGoals } from '@/lib/pm' import { getGoals, IGoals } from '@/lib/pm'
import Image from 'next/image'; import Image from "next/legacy/image";
import React from 'react'; import React from 'react';
import Link from 'next/link' import Link from 'next/link'

View File

@ -4,7 +4,7 @@ import { IStream } from "@/lib/streams";
// import NotFound from "app/streams/[cuid]/not-found"; // import NotFound from "app/streams/[cuid]/not-found";
import { IVod } from "@/lib/vods"; import { IVod } from "@/lib/vods";
import Link from "next/link"; import Link from "next/link";
import Image from "next/image"; import Image from "next/legacy/image";
import { LocalizedDate } from "./localized-date"; import { LocalizedDate } from "./localized-date";
import { FontAwesomeIcon, FontAwesomeIconProps } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon, FontAwesomeIconProps } from "@fortawesome/react-fontawesome";
import { faTriangleExclamation, faCircleInfo, faThumbsUp, IconDefinition, faO, faX, faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons"; import { faTriangleExclamation, faCircleInfo, faThumbsUp, IconDefinition, faO, faX, faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons";

View File

@ -4,7 +4,7 @@ import { LocalizedDate } from "./localized-date";
import Link from "next/link"; import Link from "next/link";
import ChaturbateIcon from "@/components/icons/chaturbate"; import ChaturbateIcon from "@/components/icons/chaturbate";
import FanslyIcon from "@/components/icons/fansly"; import FanslyIcon from "@/components/icons/fansly";
import Image from "next/image"; import Image from "next/legacy/image";
export interface IStreamProps { export interface IStreamProps {
stream: IStream; stream: IStream;

View File

@ -8,7 +8,7 @@ import {
useQuery, useQuery,
} from '@tanstack/react-query' } from '@tanstack/react-query'
import { format } from 'date-fns' import { format } from 'date-fns'
import Image from 'next/image' import Image from "next/legacy/image"
import { import {
PaginationState, PaginationState,
useReactTable, useReactTable,
@ -65,7 +65,7 @@ export default function StreamsTable() {
src={image} src={image}
alt={displayName} alt={displayName}
placeholder="blur" placeholder="blur"
objectFit='contain' objectFit='cover'
blurDataURL={imageBlur} blurDataURL={imageBlur}
width={32} width={32}
height={32} height={32}
@ -81,8 +81,11 @@ export default function StreamsTable() {
} }
}, },
{ {
header: 'Date', header: 'Date2',
accessorFn: d => format(new Date(d.attributes.date2), 'yyyy-MM-dd HH:mm'), accessorFn: d => format(new Date(d.attributes.date2), 'yyyy-MM-dd HH:mm'),
// accessorFn: d => new Date(d.attributes.date2),
sortingFn: 'datetime',
sortDescFirst: true,
cell: info => (<Link href={`/archive/${info.row.original.attributes.cuid}`}>{info.getValue() as string}</Link>) cell: info => (<Link href={`/archive/${info.row.original.attributes.cuid}`}>{info.getValue() as string}</Link>)
}, },
{ {

View File

@ -1,6 +1,6 @@
'use client' 'use client'
import LinkableHeading from "./linkable-heading" import LinkableHeading from "./linkable-heading"
import Image from "next/image" import Image from "next/legacy/image"
import { useState } from "react" import { useState } from "react"
import styles from '@/assets/styles/fp.module.css' import styles from '@/assets/styles/fp.module.css'

View File

@ -2,7 +2,7 @@ import React from 'react';
import { IToy, IToysResponse } from '@/lib/toys'; import { IToy, IToysResponse } from '@/lib/toys';
import { IVtuber } from '@/lib/vtubers'; import { IVtuber } from '@/lib/vtubers';
import Link from 'next/link'; import Link from 'next/link';
import Image from 'next/image'; import Image from "next/legacy/image";
export interface IToyProps { export interface IToyProps {
toy: IToy; toy: IToy;
@ -56,8 +56,7 @@ export function ToyItem({ toy }: IToyProps) {
src={toy.attributes.image2} src={toy.attributes.image2}
alt={displayName} alt={displayName}
objectFit='contain' objectFit='contain'
layout='fill'
fill
/> />
</figure> </figure>
<p className="heading">{toy.attributes.model}</p> <p className="heading">{toy.attributes.model}</p>

View File

@ -4,7 +4,7 @@ import { faPatreon } from "@fortawesome/free-brands-svg-icons";
import { faVideo } from "@fortawesome/free-solid-svg-icons"; import { faVideo } from "@fortawesome/free-solid-svg-icons";
import { getSafeDate, getDateFromSafeDate } from '@/lib/dates'; import { getSafeDate, getDateFromSafeDate } from '@/lib/dates';
import { IVtuber } from '@/lib/vtubers'; import { IVtuber } from '@/lib/vtubers';
import Image from 'next/image' import Image from "next/legacy/image"
import { LocalizedDate } from '@/components/localized-date' import { LocalizedDate } from '@/components/localized-date'
import { IMuxAsset, IMuxAssetResponse } from "@/lib/types"; import { IMuxAsset, IMuxAssetResponse } from "@/lib/types";
import { IB2File } from "@/lib/b2File"; import { IB2File } from "@/lib/b2File";

View File

@ -3,7 +3,7 @@
import { faVideo, faExternalLinkAlt, faShareAlt } from "@fortawesome/free-solid-svg-icons"; import { faVideo, faExternalLinkAlt, faShareAlt } from "@fortawesome/free-solid-svg-icons";
import { faXTwitter } from '@fortawesome/free-brands-svg-icons'; import { faXTwitter } from '@fortawesome/free-brands-svg-icons';
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import Image from 'next/image'; import Image from "next/legacy/image";
import Link from 'next/link'; import Link from 'next/link';
import { IVod } from '@/lib/vods'; import { IVod } from '@/lib/vods';
import { buildIpfsUrl } from '@/lib/ipfs'; import { buildIpfsUrl } from '@/lib/ipfs';

View File

@ -7,7 +7,7 @@ import { faChevronLeft, faChevronRight, faGlobe, faImage, faLink } from "@fortaw
import { notFound } from 'next/navigation'; import { notFound } from 'next/navigation';
import { IpfsCid } from './ipfs-cid'; import { IpfsCid } from './ipfs-cid';
import LinkableHeading from './linkable-heading'; import LinkableHeading from './linkable-heading';
import Image from 'next/image'; import Image from "next/legacy/image";
import Thumbnail from './thumbnail'; import Thumbnail from './thumbnail';
export function getVodTitle(vod: IVod): string { export function getVodTitle(vod: IVod): string {

View File

@ -1,4 +1,4 @@
import Image from "next/image" import Image from "next/legacy/image"
interface VtuberButtonProps { interface VtuberButtonProps {
image: string; image: string;

View File

@ -1,7 +1,7 @@
import Link from "next/link"; import Link from "next/link";
import type { IVtuber } from '@/lib/vtubers'; import type { IVtuber } from '@/lib/vtubers';
import { getVodsForVtuber } from "@/lib/vods"; import { getVodsForVtuber } from "@/lib/vods";
import Image from 'next/image' import Image from "next/legacy/image"
import NotFound from "app/vt/[slug]/not-found"; import NotFound from "app/vt/[slug]/not-found";
import ArchiveProgress from "./archive-progress"; import ArchiveProgress from "./archive-progress";

View File

@ -335,7 +335,8 @@ export async function fetchStreamData({ pageIndex, pageSize }: { pageIndex: numb
start: offset, start: offset,
limit: pageSize, limit: pageSize,
withCount: true withCount: true
} },
sort: ['date:desc']
}) })
const response = await fetch( const response = await fetch(
`${strapiUrl}/api/streams?${query}` `${strapiUrl}/api/streams?${query}`
@ -351,8 +352,9 @@ export async function fetchStreamData({ pageIndex, pageSize }: { pageIndex: numb
return d; return d;
} }
export async function getStreamCountForVtuber(vtuberId: number): Promise<IStreamsResponse> { export async function getStreamCountForVtuber(vtuberId: number, archiveStatuses = ['missing', 'issue', 'good']): Promise<number> {
if (!vtuberId) throw new Error(`getStreamCountForVtuber requires a vtuberId, but it was undefined.`); if (!vtuberId) throw new Error(`getStreamCountForVtuber requires a vtuberId, but it was undefined.`);
// @todo possible performance improvement is to only request the meta field, since we don't use any of the data.attributes
const query = qs.stringify( const query = qs.stringify(
{ {
filters: { filters: {
@ -360,13 +362,16 @@ export async function getStreamCountForVtuber(vtuberId: number): Promise<IStream
id: { id: {
$eq: vtuberId $eq: vtuberId
} }
},
archiveStatus: {
'$in': archiveStatuses
} }
} }
} }
) )
const res = await fetch(`${strapiUrl}/api/streams?${query}`, fetchStreamsOptions) const res = await fetch(`${strapiUrl}/api/streams?${query}`, fetchStreamsOptions)
const data = await res.json() const data = await res.json()
console.log('getStreamCountForVtuber') console.log(`getStreamCountForVtuber with archiveStatuses=${archiveStatuses}`)
console.log(JSON.stringify(data, null, 2)) console.log(JSON.stringify(data, null, 2))
return data.meta.pagination.total return data.meta.pagination.total
} }

View File

@ -4,7 +4,7 @@ import { getVtuberBySlug } from '@/lib/vtubers'
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faExternalLinkAlt, faBagShopping } from "@fortawesome/free-solid-svg-icons"; import { faExternalLinkAlt, faBagShopping } from "@fortawesome/free-solid-svg-icons";
import { faFacebook, faInstagram, faPatreon, faYoutube, faTwitch, faTiktok, faXTwitter, faReddit, faDiscord } from "@fortawesome/free-brands-svg-icons"; import { faFacebook, faInstagram, faPatreon, faYoutube, faTwitch, faTiktok, faXTwitter, faReddit, faDiscord } from "@fortawesome/free-brands-svg-icons";
import Image from 'next/image'; import Image from "next/legacy/image";
import OnlyfansIcon from "@/components/icons/onlyfans"; import OnlyfansIcon from "@/components/icons/onlyfans";
import PornhubIcon from '@/components/icons/pornhub'; import PornhubIcon from '@/components/icons/pornhub';
import ThroneIcon from '@/components/icons/throne'; import ThroneIcon from '@/components/icons/throne';
@ -63,7 +63,7 @@ export default async function Page({ params }: { params: { slug: string } }) {
className="is-rounded" className="is-rounded"
alt={vtuber.attributes.displayName} alt={vtuber.attributes.displayName}
src={vtuber.attributes.image} src={vtuber.attributes.image}
fill={true} layout='fill'
objectFit='cover' objectFit='cover'
placeholder='blur' placeholder='blur'
blurDataURL={vtuber.attributes.imageBlur} blurDataURL={vtuber.attributes.imageBlur}

View File

@ -79,7 +79,7 @@ module.exports = {
* If any platformNotification is from chaturbate, isChaturbateStream is set to true. * If any platformNotification is from chaturbate, isChaturbateStream is set to true.
*/ */
const existingData2 = await strapi.entityService.findOne("api::stream.stream", id, { const existingData2 = await strapi.entityService.findOne("api::stream.stream", id, {
populate: ['platform_notifications'] populate: {'platformNotifications': true}
}) })
let isFanslyStream = false let isFanslyStream = false
@ -89,7 +89,7 @@ module.exports = {
console.log(JSON.stringify(existingData2, null, 2)) console.log(JSON.stringify(existingData2, null, 2))
// Iterate through all platformNotifications to determine platform // Iterate through all platformNotifications to determine platform
if (existingData2.platformNotifications) { if (existingData2?.platformNotifications) {
for (const pn of existingData2.platformNotifications) { for (const pn of existingData2.platformNotifications) {
if (pn.platform === 'fansly') { if (pn.platform === 'fansly') {
isFanslyStream = true isFanslyStream = true