mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 01:35:39 -04:00
Revert "Persist dashboard periods and explore genre filters in URL via nuqs"
This reverts commit 2bb5af042b.
This commit is contained in:
@@ -122,8 +122,8 @@ describe("getUserStats", () => {
|
||||
insertStatus("user-1", titleId, "in_progress");
|
||||
|
||||
const stats = getUserStats("user-1");
|
||||
expect(stats.movieCount).toBe(2);
|
||||
expect(stats.episodeCount).toBe(1);
|
||||
expect(stats.moviesThisMonth).toBe(2);
|
||||
expect(stats.episodesThisWeek).toBe(1);
|
||||
expect(stats.librarySize).toBe(3);
|
||||
expect(stats.completed).toBe(2);
|
||||
});
|
||||
@@ -131,8 +131,8 @@ describe("getUserStats", () => {
|
||||
test("returns zeros when no data", () => {
|
||||
insertUser();
|
||||
const stats = getUserStats("user-1");
|
||||
expect(stats.movieCount).toBe(0);
|
||||
expect(stats.episodeCount).toBe(0);
|
||||
expect(stats.moviesThisMonth).toBe(0);
|
||||
expect(stats.episodesThisWeek).toBe(0);
|
||||
expect(stats.librarySize).toBe(0);
|
||||
expect(stats.completed).toBe(0);
|
||||
});
|
||||
|
||||
@@ -144,19 +144,15 @@ export function getWatchHistory(
|
||||
}
|
||||
|
||||
export interface DashboardStats {
|
||||
movieCount: number;
|
||||
episodeCount: number;
|
||||
moviesThisMonth: number;
|
||||
episodesThisWeek: number;
|
||||
librarySize: number;
|
||||
completed: number;
|
||||
}
|
||||
|
||||
export function getUserStats(
|
||||
userId: string,
|
||||
moviePeriod: TimePeriod = "this_month",
|
||||
episodePeriod: TimePeriod = "this_week",
|
||||
): DashboardStats {
|
||||
const movieCount = getWatchCount(userId, "movies", moviePeriod);
|
||||
const episodeCount = getWatchCount(userId, "episodes", episodePeriod);
|
||||
export function getUserStats(userId: string): DashboardStats {
|
||||
const moviesThisMonth = getWatchCount(userId, "movies", "this_month");
|
||||
const episodesThisWeek = getWatchCount(userId, "episodes", "this_week");
|
||||
|
||||
const [statusCounts] = db
|
||||
.select({
|
||||
@@ -168,8 +164,8 @@ export function getUserStats(
|
||||
.all();
|
||||
|
||||
return {
|
||||
movieCount,
|
||||
episodeCount,
|
||||
moviesThisMonth,
|
||||
episodesThisWeek,
|
||||
librarySize: statusCounts?.librarySize ?? 0,
|
||||
completed: statusCounts?.completed ?? 0,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user