tangled
alpha
login
or
join now
t1c.dev
/
rocksky
forked from
rocksky.app/rocksky
2
fork
atom
A decentralized music tracking and discovery platform built on AT Protocol 🎵
2
fork
atom
overview
issues
pulls
pipelines
Use case-insensitive matching for song fields
tsiry-sandratraina.com
2 months ago
fc9453c1
4a1f8343
+17
-17
2 changed files
expand all
collapse all
unified
split
apps
api
src
xrpc
app
rocksky
song
matchSong.ts
cli
src
scrobble.ts
+5
-5
apps/api/src/xrpc/app/rocksky/song/matchSong.ts
···
1
1
import type { Context } from "context";
2
2
-
import { and, count, eq, or } from "drizzle-orm";
2
2
+
import { and, count, eq, or, sql } from "drizzle-orm";
3
3
import { Effect, pipe } from "effect";
4
4
import type { Server } from "lexicon";
5
5
import type { SongViewDetailed } from "lexicon/types/app/rocksky/song/defs";
···
66
66
.where(
67
67
or(
68
68
and(
69
69
-
eq(tables.tracks.title, params.title),
70
70
-
eq(tables.tracks.artist, params.artist),
69
69
+
sql`LOWER(${tables.tracks.title}) = LOWER(${params.title})`,
70
70
+
sql`LOWER(${tables.tracks.artist}) = LOWER(${params.artist})`,
71
71
),
72
72
and(
73
73
-
eq(tables.tracks.title, params.title),
74
74
-
eq(tables.tracks.albumArtist, params.artist),
73
73
+
sql`LOWER(${tables.tracks.title}) = LOWER(${params.title})`,
74
74
+
sql`LOWER(${tables.tracks.albumArtist}) = LOWER(${params.artist})`,
75
75
),
76
76
),
77
77
)
+12
-12
apps/cli/src/scrobble.ts
···
68
68
.where(
69
69
or(
70
70
and(
71
71
-
eq(schema.tracks.title, track.title),
72
72
-
eq(schema.tracks.artist, track.artist),
71
71
+
sql`LOWER(${schema.tracks.title}) = LOWER(${track.title})`,
72
72
+
sql`LOWER(${schema.tracks.artist}) = LOWER(${track.artist})`,
73
73
),
74
74
and(
75
75
-
eq(schema.tracks.title, track.title),
76
76
-
eq(schema.tracks.albumArtist, track.artist),
75
75
+
sql`LOWER(${schema.tracks.title}) = LOWER(${track.title})`,
76
76
+
sql`LOWER(${schema.tracks.albumArtist}) = LOWER(${track.artist})`,
77
77
),
78
78
and(
79
79
-
eq(schema.tracks.title, track.title),
80
80
-
eq(schema.tracks.albumArtist, track.albumArtist),
79
79
+
sql`LOWER(${schema.tracks.title}) = LOWER(${track.title})`,
80
80
+
sql`LOWER(${schema.tracks.albumArtist}) = LOWER(${track.albumArtist})`,
81
81
),
82
82
),
83
83
)
···
94
94
.from(schema.artists)
95
95
.where(
96
96
or(
97
97
-
eq(schema.artists.name, track.artist),
98
98
-
eq(schema.artists.name, track.albumArtist),
97
97
+
sql`LOWER(${schema.artists.name}) = LOWER(${track.artist})`,
98
98
+
sql`LOWER(${schema.artists.name}) = LOWER(${track.albumArtist})`,
99
99
),
100
100
)
101
101
.limit(1)
···
111
111
.from(schema.albums)
112
112
.where(
113
113
and(
114
114
-
eq(schema.albums.title, track.album),
115
115
-
eq(schema.albums.artist, track.albumArtist),
114
114
+
sql`LOWER(${schema.albums.title}) = LOWER(${track.album})`,
115
115
+
sql`LOWER(${schema.albums.artist}) = LOWER(${track.albumArtist})`,
116
116
),
117
117
)
118
118
.limit(1)
···
146
146
.where(
147
147
and(
148
148
eq(schema.users.did, did),
149
149
-
eq(schema.tracks.title, track.title),
150
150
-
eq(schema.tracks.artist, track.artist),
149
149
+
sql`LOWER(${schema.tracks.title}) = LOWER(${track.title})`,
150
150
+
sql`LOWER(${schema.tracks.artist}) = LOWER(${track.artist})`,
151
151
gte(
152
152
schema.scrobbles.timestamp,
153
153
scrobbleTime.subtract(60, "seconds").toDate(),