A decentralized music tracking and discovery platform built on AT Protocol 🎵

Replace local QueryFilter with drizzle-orm operators

+286 -408
+5 -8
apps/feeds/src/algos/afrobeat.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["afrobeat"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["afrobeat"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/afrobeats.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["afrobeats"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["afrobeats"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/alternative-metal.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["alternative metal"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["alternative metal"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+7 -8
apps/feeds/src/algos/alternative-rnb.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["alternative rnb"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["alternative rnb"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/anime.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["anime"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["anime"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+6 -8
apps/feeds/src/algos/art-pop.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq } from "drizzle-orm"; 5 + import { lt } from "drizzle-orm/sql"; 9 6 10 7 const handler = async ( 11 8 ctx: Context, ··· 14 11 ) => { 15 12 const { limit = 50, cursor } = params; 16 13 17 - const query: QueryFilter = {}; 14 + const whereConditions = [arrayContains(schema.artists.genres, ["art pop"])]; 18 15 19 16 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 17 + const cursorDate = new Date(parseInt(cursor, 10)); 18 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 19 } 22 20 23 21 const scrobbles = await ctx.db 24 22 .select() 25 23 .from(schema.scrobbles) 26 24 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["art pop"])) 25 + .where(and(...whereConditions)) 28 26 .orderBy(desc(schema.scrobbles.timestamp)) 29 27 .limit(limit) 30 28 .execute();
+5 -8
apps/feeds/src/algos/breakcore.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["breakcore"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["breakcore"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/chicago-drill.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["chicago drill"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["chicago drill"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/chillwave.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["chillwave"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["chillwave"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/country-hip-hop.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["country hip hop"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["country hip hop"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/crunk.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["crunk"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["crunk"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/dance-pop.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["dance pop"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["dance pop"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/deep-house.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["deep house"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["deep house"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/drill.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["drill"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["drill"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/dubstep.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["dubstep"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["dubstep"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/emo.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["emo"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["emo"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/grunge.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["grunge"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["grunge"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/hard-rock.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["hard rock"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["hard rock"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/heavy-metal.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["heavy metal"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["heavy metal"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/hip-hop.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["hip hop"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["hip hop"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/house.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["house"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["house"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/hyperpop.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["hyperpop"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["hyperpop"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/indie-rock.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["indie rock"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["indie rock"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/indie.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["indie"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["indie"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/j-pop.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["j-pop"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["j-pop"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/j-rock.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["j-rock"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["j-rock"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/jazz.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["jazz"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["jazz"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/k-pop.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["k-pop"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["k-pop"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/lo-fi.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["lo-fi"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["lo-fi"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/metal.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["metal"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["metal"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/metalcore.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["metalcore"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["metalcore"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/midwest-emo.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["midwest emo"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["midwest emo"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/nu-metal.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["nu metal"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["nu metal"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/pop-punk.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["pop punk"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["pop punk"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/post-grunge.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["post-grunge"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["post grunge"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/rap-metal.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["rap-metal"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["rap metal"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/rap.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["rap"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["rap"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/rnb.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["rnb"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["rnb"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/rock.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["rock"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["rock"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/southern-hip-hop.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["southern hip hop"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["southern hip hop"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/speedcore.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["speedcore"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["speedcore"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/swedish-pop.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["swedish pop"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["swedish pop"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/synthwave.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["synthwave"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["synthwave"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/thrash-metal.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["thrash metal"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["thrash metal"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/trap-soul.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["trap soul"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["trap soul"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+5 -8
apps/feeds/src/algos/trap.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["trap"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["trap"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/tropical-house.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["tropical house"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["tropical house"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/vaporwave.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["vaporwave"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["vaporwave"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/visual-kei.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["visual kei"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["visual kei"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();
+5 -8
apps/feeds/src/algos/vocaloid.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [arrayContains(schema.artists.genres, ["vocaloid"])]; 18 14 19 15 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 16 + const cursorDate = new Date(parseInt(cursor, 10)); 17 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 18 } 22 19 23 20 const scrobbles = await ctx.db 24 21 .select() 25 22 .from(schema.scrobbles) 26 23 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["vocaloid"])) 24 + .where(and(...whereConditions)) 28 25 .orderBy(desc(schema.scrobbles.timestamp)) 29 26 .limit(limit) 30 27 .execute();
+7 -8
apps/feeds/src/algos/west-coast-hip-hop.ts
··· 1 1 import { Context } from "../context.ts"; 2 2 import { Algorithm, feedParams } from "./types.ts"; 3 3 import schema from "../schema/mod.ts"; 4 - import { arrayContains, desc, eq } from "drizzle-orm"; 5 - 6 - interface QueryFilter { 7 - indexedAt?: { $lt: Date }; 8 - } 4 + import { and, arrayContains, desc, eq, lt } from "drizzle-orm"; 9 5 10 6 const handler = async ( 11 7 ctx: Context, ··· 14 10 ) => { 15 11 const { limit = 50, cursor } = params; 16 12 17 - const query: QueryFilter = {}; 13 + const whereConditions = [ 14 + arrayContains(schema.artists.genres, ["west coast hip hop"]), 15 + ]; 18 16 19 17 if (cursor) { 20 - query.indexedAt = { $lt: new Date(parseInt(cursor, 10)) }; 18 + const cursorDate = new Date(parseInt(cursor, 10)); 19 + whereConditions.push(lt(schema.scrobbles.timestamp, cursorDate)); 21 20 } 22 21 23 22 const scrobbles = await ctx.db 24 23 .select() 25 24 .from(schema.scrobbles) 26 25 .leftJoin(schema.artists, eq(schema.scrobbles.artistId, schema.artists.id)) 27 - .where(arrayContains(schema.artists.genres, ["west coast hip hop"])) 26 + .where(and(...whereConditions)) 28 27 .orderBy(desc(schema.scrobbles.timestamp)) 29 28 .limit(limit) 30 29 .execute();