mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[PR #1055] [MERGED] strongly type ActivityPeriod #1212
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#1212
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/librespot-org/librespot/pull/1055
Author: @eladyn
Created: 8/31/2022
Status: ✅ Merged
Merged: 9/3/2022
Merged by: @roderickvd
Base:
dev← Head:strong_activity_periods📝 Commits (3)
df0d50fstrongly type ActivityPeriods0c5926duse fallible conversion for ActivityPeriod07336c2switch fallibly to unsigned integers📊 Changes
2 files changed (+44 additions, -14 deletions)
View changed files
📝
core/src/error.rs(+12 -1)📝
metadata/src/artist.rs(+32 -13)📄 Description
From my observations,
ActivityPeriodalways comes in one of the following three compositions:decadestart_year(open timespan)start_year+end_year(closed timespan)Thus, it probably makes sense to strongly type those variants into
ActivityPeriod.I also added two
debug_assert!s that make sure that the invariants that I assume are always held up. Alternatively, I could also turn them into normalassert!s or handle-able exceptions throughTryFrom. I went for the current variants, since I think it makes most sense, but I'm open to different perspectives!I've verified my assumptions with the help of the below program for probably around 1000 different artists, so it should be fine? Some example outputs:
spotify:artist:5WUlDfRSoLAfcVSX1WnrxN:known good artists: 470 (decades: 203, closed: 4, open: 31)spotify:artist:3fMbdgg4jU18AjLCKBhRSm:known good artists: 333 (decades: 966, closed: 112, open: 216)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.