Remove categories and sorting options from the video search filters
Removes category/sort selection from UI and `/api/videos`, updates `getVideos`/`getVideoCount` in `storage.ts`, and removes `/api/categories` route. Replit-Commit-Author: Agent Replit-Commit-Session-Id: aa92e7e2-ec62-4c92-b21b-02ef78a664c2 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/aa92e7e2-ec62-4c92-b21b-02ef78a664c2/Cz5fe6k
This commit is contained in:
+10
-20
@@ -3,11 +3,11 @@ import { randomUUID } from "crypto";
|
||||
import { BunnyService } from "./bunny";
|
||||
|
||||
export interface IStorage {
|
||||
getVideos(limit?: number, offset?: number, search?: string, category?: string): Promise<Video[]>;
|
||||
getVideos(limit?: number, offset?: number, search?: string): Promise<Video[]>;
|
||||
getVideo(id: string): Promise<Video | undefined>;
|
||||
createVideo(video: InsertVideo): Promise<Video>;
|
||||
updateVideoViews(id: string): Promise<void>;
|
||||
getVideoCount(search?: string, category?: string): Promise<number>;
|
||||
getVideoCount(search?: string): Promise<number>;
|
||||
}
|
||||
|
||||
export class MemStorage implements IStorage {
|
||||
@@ -92,7 +92,7 @@ export class MemStorage implements IStorage {
|
||||
});
|
||||
}
|
||||
|
||||
async getVideos(limit = 20, offset = 0, search?: string, category?: string): Promise<Video[]> {
|
||||
async getVideos(limit = 20, offset = 0, search?: string): Promise<Video[]> {
|
||||
let videos = Array.from(this.videos.values());
|
||||
|
||||
// Filter by search
|
||||
@@ -104,11 +104,6 @@ export class MemStorage implements IStorage {
|
||||
);
|
||||
}
|
||||
|
||||
// Filter by category
|
||||
if (category && category !== "All Categories") {
|
||||
videos = videos.filter(video => video.category === category);
|
||||
}
|
||||
|
||||
// Sort by created date (newest first)
|
||||
videos.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
||||
|
||||
@@ -141,8 +136,8 @@ export class MemStorage implements IStorage {
|
||||
}
|
||||
}
|
||||
|
||||
async getVideoCount(search?: string, category?: string): Promise<number> {
|
||||
const videos = await this.getVideos(1000, 0, search, category);
|
||||
async getVideoCount(search?: string): Promise<number> {
|
||||
const videos = await this.getVideos(1000, 0, search);
|
||||
return videos.length;
|
||||
}
|
||||
}
|
||||
@@ -156,11 +151,11 @@ class BunnyStorage implements IStorage {
|
||||
this.bunnyService = new BunnyService();
|
||||
}
|
||||
|
||||
async getVideos(limit = 20, offset = 0, search?: string, category?: string): Promise<Video[]> {
|
||||
async getVideos(limit = 20, offset = 0, search?: string): Promise<Video[]> {
|
||||
try {
|
||||
// For search/filtering, we need to get more videos than the requested limit
|
||||
// For search filtering, we need to get more videos than the requested limit
|
||||
// because we'll filter client-side and then slice to the requested amount
|
||||
const fetchLimit = (search || category) ? 100 : limit;
|
||||
const fetchLimit = search ? 100 : limit;
|
||||
const page = Math.floor(offset / fetchLimit) + 1;
|
||||
|
||||
// Get videos from Bunny API
|
||||
@@ -177,11 +172,6 @@ class BunnyStorage implements IStorage {
|
||||
(video.description && video.description.toLowerCase().includes(searchLower))
|
||||
);
|
||||
}
|
||||
|
||||
// Filter by category if specified
|
||||
if (category && category !== "All Categories") {
|
||||
filteredVideos = filteredVideos.filter(video => video.category === category);
|
||||
}
|
||||
|
||||
// Apply cached view counts
|
||||
filteredVideos.forEach(video => {
|
||||
@@ -228,10 +218,10 @@ class BunnyStorage implements IStorage {
|
||||
this.viewsCache.set(id, currentViews + 1);
|
||||
}
|
||||
|
||||
async getVideoCount(search?: string, category?: string): Promise<number> {
|
||||
async getVideoCount(search?: string): Promise<number> {
|
||||
try {
|
||||
// For accurate count with client-side filtering, we need to get all videos and filter them
|
||||
const allVideos = await this.getVideos(1000, 0, search, category);
|
||||
const allVideos = await this.getVideos(1000, 0, search);
|
||||
return allVideos.length;
|
||||
} catch (error) {
|
||||
console.error('Error getting video count from Bunny:', error);
|
||||
|
||||
Reference in New Issue
Block a user