Commit graph

148 commits

Author SHA1 Message Date
36873053bc Make new scrobble processing function
This uses the zmpl data as a hash map to check if we've already checked the db for some song/album/artist/etc. and now only checks once per entity/assoc. table entry to speed things up. Previously, for each scrobble, we checked if its metadata appeared in the respective table, regardless of whether or not we've scrobbled that albumsong before. So, a song like Starless had to be checked (at the time of writing) ~180 times, but is now only checked once. Similarly, Wilco was checked ~3000+ times, as Hurry Up, We're Dreaming was cheked ~700 times.

The only problem now is the way it was implemented. Obviously, copying and pasting those huge chunks of code isn't very nice looking. ATM, I don't really care, and I'm more happy about the overall speed increase, as well as the readability increase of the job. However, I don't want to leave it like that. The way I see it, I have two options: either create a funcion which does this, or I can do something even better, which is create a jsonParse function, which, if my thought process works, would remove the need for an intermediary source type, meaning we no longer need to switch on that type, which means we can just have one for loop that does everything, which would mean we just need to have that code in one place.

Also not entirely happy with the code concerning all the conversions to i64s and []const u8s, but I think I have to.
2025-06-11 20:08:13 -04:00
df8f01525e Merge remote-tracking branch 'refs/remotes/origin/rawsql' into rawsql 2025-06-11 09:28:14 -04:00
2f420bc5ce Testing with groups and htmx 2025-06-11 09:26:12 -04:00
6a1c822420 Add entities_by_name query
Will probably be used for disambiguation pages (among other things, but disambiguation pages are coming up soon)
2025-06-11 09:25:40 -04:00
a8a4ed27c4 Make process_scrobbles vars more readable, and change hashing 2025-06-11 09:22:38 -04:00
1e4a271b8d Update README 2025-06-11 09:22:06 -04:00
85552f39c1 Add Artistsongs table
Whether or not a song is covered, there was an original artist who originally performed the song. The only issue is that an Artistsongs table will almost be the exact same as the Albumsongsartists table, since most songs aren't covered. So, it may be better not to populate that table by default, and then if two albumsongs with different artists share the same song, then fill the Artistsongs table.
2025-06-09 21:45:41 -04:00
162341fb5f Convert ids to i64
The birthday paradox is a real problem with the size of our datasets. i64 is the largest numerical value we can use, and there's a 0.1% chance of collision with ~2,000,000 values, so I feel pretty comfortable with this
2025-06-09 21:41:52 -04:00
c8f2ef57c8 Add some tyling to songs view
This can (will) be easily replicated for the other views, I just first tested it on songs. I think this looks much nicer, and I'll probably roll with a layout similar to this for the other views, with some minor adjustments for each particular view.
2025-06-06 15:55:20 -04:00
3ef17fcd46 Split entity_items and appears query into more granular queries
We can be a bit more specific about the information we get this way
2025-06-06 14:28:15 -04:00
adcaff34ea Fix dumb appears query for albums 2025-06-02 00:13:27 -04:00
566edf1818 Include artist(s) name in album GET view
This also makes the entity_info struct very similar to the UnifiedResult struct, so we'll probably see a merge at some point. Would be nice if we used the fields from the entity_info result more commonly.
2025-05-31 15:48:30 -04:00
906ba6d2e5 Update header partial and remoev table partial
Long overdue
2025-05-31 14:47:52 -04:00
3777b818e3 Create view for groups
One of the largest components that makes zuletzt unique - implementing groups the way MusicBrainz has (release groups in particular). I thought for a while that I would just connect songs via a shared ID, but for remixes and such, I don't think they should be so tightly coupled. This also gives the user freedom for how they want to do the grouping (a remix can be included in the group if they choose to, or it may not). This will allow someone to see a combined scrobble number for an album with, for example, a regular release, a deluxe release, and an anniversary release, in addition to the individual releases. This will complicate SQL queries rather significantly I imagine, and I'm not sure what the interface for creating/deleting groups will be (although it will likely be easier when I have full use of TS), but it's a necessity for the project.
2025-05-31 14:45:45 -04:00
a314fd447d Fix LastFM API scrobble parsing when song is currently playing 2025-05-31 14:31:15 -04:00
c57bf18627 Update queries
Adds datestreak query, provides the number of songs/albums when relevant, and provides timescale with all years, regardless of the number of plays (defaults to 0)
2025-05-31 13:39:03 -04:00
d81681e698 Move scrobble rank from firstlast partial to view.
Eventually moving this to its own partial (probably)
2025-05-31 13:37:34 -04:00
62590fee37 Made queries.zig look significantly nicer
There's a little bit of weird stuff happening, but holy cannoli, that's so much easier to maintain and parse
2025-05-29 19:39:51 -04:00
d638fa66c5 Create GET function for a song view 2025-05-29 15:33:10 -04:00
3ff973e193 Use queries.zig in scrobbles view 2025-05-26 11:15:51 -04:00
f59eec79a8 Removed inline else from upload.zig
If I can figure out a way to get an array of a union instead of a union of arrays, we're in business to make this even better, but this is fine right now. The inline else was just a dumb way to keep the for on the outside
2025-05-26 11:15:19 -04:00
aab61631a3 Directly append complete_scrobble in upload.zig
Thanks bob :)
2025-05-25 16:16:18 -04:00
7f3778e82f Move SQL logic to separate function
Idk if this makes any sense, and I don't really like the code atm, but the view .zig files lookk nicer?
2025-05-24 13:59:28 -04:00
09f542e26e Add timescale partial
Bad name, idk what else to call it
2025-05-24 13:58:31 -04:00
1734e6a4bb Fix date formatting in scrobble view 2025-05-20 16:29:53 -04:00
d6a638bf27 Merge remote-tracking branch 'refs/remotes/origin/rawsql' into rawsql 2025-05-20 15:10:49 -04:00
a2a739bc9c Refactor upload.zig
I have been unhappy with the branches, but didn't quite know what to do about it. THis feels much nicer. Also fixes datetime stuff with jetquery.  The HTML element parsing isn't quite where I want it to be, but it works for the time being.
2025-05-20 15:07:51 -04:00
6494bbdf60 Remove Rules type 2025-05-20 09:33:15 -04:00
4c759433d2 Update README.md 2025-05-16 05:06:59 +00:00
614607ae71 Fix LastFM uploadig error
I figured it out; if you have a song currently being played, then it doesn't have a date
2025-05-16 01:05:32 -04:00
5697f95355 Fix LastFM uploading errors
Not sure which of these actually made it work, will probably work backwards at some point to reverse engineer it
2025-05-15 20:23:53 -04:00
89e98c7a47 Allow uploads from LastFM API
Very slow at the moment. Look into ways to speed this up
2025-05-15 20:23:12 -04:00
f69ffb2b37 Move upload.zig to the new table partial 2025-05-15 20:22:34 -04:00
52fefc9ba5 Create dateCompare function
Will eventually try to move away from zeit. Don't need all of it's functionality as long as SQL can format dates
2025-05-15 20:22:09 -04:00
4991bac9a4 Add LastFM scrobble type
In preparation for importing via LastFM api
2025-05-15 15:39:21 -04:00
c42b8d24dd Fix typo 2025-05-15 15:37:21 -04:00
365b9dbf11 Switch to using newtable partial for all tables
Will be renamed eventually, don't care right now. Also cleans up a lot of code I wasn't particularly happy about
2025-05-13 14:24:14 -04:00
153ea869e0 Work on making partials for views 2025-05-08 18:17:45 -04:00
4758885c68 Keep cleaning 2025-05-05 13:09:16 -04:00
9ffc45b207 Delete common_queries.md
No longer relevant
2025-05-05 11:15:30 -04:00
94cc6e3bd5 Remove unused views and functions 2025-05-05 11:06:52 -04:00
c574885f8d Get rid of unused views 2025-05-05 10:37:18 -04:00
762a4fd51e Create partial for view agnostic table 2025-05-02 10:00:47 -04:00
3345b20f1f Make an ordinal formatting funcrion
I am hungry
2025-04-29 00:38:20 -04:00
78e416eeaf Add more information to scrobbles views and refactor artists view 2025-04-28 23:06:21 -04:00
8138e5ccf2 Create dateFmt function
It's easier to keep the date as an epoch in PostgreSQL to do comparisons, but I always want to show it to the user as a formatted date
2025-04-28 23:03:24 -04:00
ae85f94ddb Switch dates from u64 to i64
PostgreSQL only uses signed ints, so this makes things much easier
2025-04-28 23:01:34 -04:00
cb89a3e6f3 Switch dates from i128 to u64
I was making them unnecessarily large by accidentally storing them as microseconds instead of milliseconds. Might be able to get away with seconds in the future
2025-04-28 21:37:08 -04:00
65136a44d6 Add more information to artists view, songs view, and format dates correctly in scrobbles view 2025-04-27 23:58:50 -04:00
01fe10f045 Fix limit on rule parameters and fix segfault in applyScrobbleRule
For sure this time
2025-04-27 16:27:03 -04:00