This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

chore: remove unused DrizzleCardLibraryQueryService and interface

These service files are no longer used in the codebase. All their
functionality has been replaced by direct queries using authorId
in the query services.

Deleted files:
- src/modules/cards/application/services/ICardLibraryQueryService.ts
- src/modules/cards/infrastructure/services/DrizzleCardLibraryQueryService.ts

-124
-29
src/modules/cards/application/services/ICardLibraryQueryService.ts
··· 1 - import { Result } from '../../../../shared/core/Result'; 2 - import { CardId } from '../../domain/value-objects/CardId'; 3 - 4 - export interface ICardLibraryQueryService { 5 - /** 6 - * Get all user IDs who have this card in their library 7 - */ 8 - getLibrariesForCard(cardId: CardId): Promise<Result<string[]>>; 9 - 10 - /** 11 - * Get all card IDs in a user's library 12 - */ 13 - getCardsInLibrary(userId: string): Promise<Result<CardId[]>>; 14 - 15 - /** 16 - * Check if a specific card is in a user's library 17 - */ 18 - isCardInLibrary(cardId: CardId, userId: string): Promise<Result<boolean>>; 19 - 20 - /** 21 - * Get library membership count for a card 22 - */ 23 - getLibraryMembershipCount(cardId: CardId): Promise<Result<number>>; 24 - 25 - /** 26 - * Get total number of cards in a user's library 27 - */ 28 - getLibraryCardCount(userId: string): Promise<Result<number>>; 29 - }
-95
src/modules/cards/infrastructure/services/DrizzleCardLibraryQueryService.ts
··· 1 - import { eq, and, count } from 'drizzle-orm'; 2 - import { PostgresJsDatabase } from 'drizzle-orm/postgres-js'; 3 - import { ICardLibraryQueryService } from '../../application/services/ICardLibraryQueryService'; 4 - import { CardId } from '../../domain/value-objects/CardId'; 5 - import { libraryMemberships } from '../repositories/schema/libraryMembership.sql'; 6 - import { cards } from '../repositories/schema/card.sql'; 7 - import { Result, ok, err } from '../../../../shared/core/Result'; 8 - 9 - export class DrizzleCardLibraryQueryService 10 - implements ICardLibraryQueryService 11 - { 12 - constructor(private db: PostgresJsDatabase) {} 13 - 14 - async getLibrariesForCard(cardId: CardId): Promise<Result<string[]>> { 15 - try { 16 - const results = await this.db 17 - .select({ userId: libraryMemberships.userId }) 18 - .from(libraryMemberships) 19 - .where(eq(libraryMemberships.cardId, cardId.getStringValue())); 20 - 21 - return ok(results.map((r) => r.userId)); 22 - } catch (error) { 23 - return err(error as Error); 24 - } 25 - } 26 - 27 - async getCardsInLibrary(userId: string): Promise<Result<CardId[]>> { 28 - try { 29 - const results = await this.db 30 - .select({ id: cards.id }) 31 - .from(cards) 32 - .where(eq(cards.authorId, userId)); 33 - 34 - const cardIds: CardId[] = []; 35 - for (const result of results) { 36 - const cardIdResult = CardId.createFromString(result.id); 37 - if (cardIdResult.isOk()) { 38 - cardIds.push(cardIdResult.value); 39 - } 40 - } 41 - 42 - return ok(cardIds); 43 - } catch (error) { 44 - return err(error as Error); 45 - } 46 - } 47 - 48 - async isCardInLibrary( 49 - cardId: CardId, 50 - userId: string, 51 - ): Promise<Result<boolean>> { 52 - try { 53 - const result = await this.db 54 - .select({ id: cards.id }) 55 - .from(cards) 56 - .where( 57 - and( 58 - eq(cards.id, cardId.getStringValue()), 59 - eq(cards.authorId, userId), 60 - ), 61 - ) 62 - .limit(1); 63 - 64 - return ok(result.length > 0); 65 - } catch (error) { 66 - return err(error as Error); 67 - } 68 - } 69 - 70 - async getLibraryMembershipCount(cardId: CardId): Promise<Result<number>> { 71 - try { 72 - const results = await this.db 73 - .select({ userId: libraryMemberships.userId }) 74 - .from(libraryMemberships) 75 - .where(eq(libraryMemberships.cardId, cardId.getStringValue())); 76 - 77 - return ok(results.length); 78 - } catch (error) { 79 - return err(error as Error); 80 - } 81 - } 82 - 83 - async getLibraryCardCount(userId: string): Promise<Result<number>> { 84 - try { 85 - const result = await this.db 86 - .select({ count: count() }) 87 - .from(cards) 88 - .where(eq(cards.authorId, userId)); 89 - 90 - return ok(result[0]?.count || 0); 91 - } catch (error) { 92 - return err(error as Error); 93 - } 94 - } 95 - }