mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-10-16 05:25:42 -04:00
fix(discovery): only offer aired episodes in Continue Watching; unify "today"
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
7 files changed
+163
-43
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import { and, asc, desc, eq, gte, inArray, lte, sql } from "drizzle-orm";
|
||||
|
||||
import { localDateString } from "@sofa/config";
|
||||
|
||||
import { db } from "../client";
|
||||
import {
|
||||
episodes,
|
||||
@@ -82,7 +84,7 @@ export function getUserStatusCounts(userId: string) {
|
||||
.all();
|
||||
|
||||
// Count TV shows where all aired episodes are watched (caught_up + completed display states)
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const today = localDateString();
|
||||
const [tvRow] = db
|
||||
.select({ count: sql<number>`count(*)` })
|
||||
.from(userTitleStatus)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { and, asc, countDistinct, desc, eq, gte, isNotNull, lte, sql } from "drizzle-orm";
|
||||
|
||||
import { localDateString } from "@sofa/config";
|
||||
|
||||
import { db } from "../client";
|
||||
import {
|
||||
episodes,
|
||||
@@ -51,7 +53,7 @@ function watchedEpisodeCount(
|
||||
}
|
||||
|
||||
function displayStatusExpr() {
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const today = localDateString();
|
||||
const aired = airedEpisodeCount(titles.id, today);
|
||||
const watched = watchedEpisodeCount(titles.id, userTitleStatus.userId, today);
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { and, eq, inArray, sql } from "drizzle-orm";
|
||||
|
||||
import { localDateString } from "@sofa/config";
|
||||
|
||||
import { db } from "../client";
|
||||
import {
|
||||
episodes,
|
||||
@@ -226,7 +228,7 @@ export function getUserStatusesByTitleIds(userId: string, titleIds: string[]) {
|
||||
|
||||
export function getEpisodeProgressByTitleIds(userId: string, titleIds: string[]) {
|
||||
if (titleIds.length === 0) return [];
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const today = localDateString();
|
||||
return db
|
||||
.select({
|
||||
titleId: titles.id,
|
||||
|
||||
Reference in new issue
Block a user