Skip to content

Commit

Permalink
fix deduplication of included entities
Browse files Browse the repository at this point in the history
Closes #3
  • Loading branch information
lucat1 committed Dec 9, 2023
1 parent af2aca7 commit 8b7c33d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/src/api/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ pub enum Included {
impl PartialEq for Included {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Included::User(a), Included::User(b)) => a.id == b.id,
(Included::Scrobble(a), Included::Scrobble(b)) => a.id == b.id,
(Included::Image(a), Included::Image(b)) => a.id == b.id,
(Included::Artist(a), Included::Artist(b)) => a.id == b.id,
(Included::Track(a), Included::Track(b)) => a.id == b.id,
(Included::Medium(a), Included::Medium(b)) => a.id == b.id,
(Included::Release(a), Included::Release(b)) => a.id == b.id,
(Included::Genre(a), Included::Genre(b)) => a.id == b.id,
(_, _) => false,
}
}
Expand All @@ -85,11 +88,14 @@ impl std::cmp::PartialOrd for Included {
impl std::cmp::Ord for Included {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
match (self, other) {
(Included::User(a), Included::User(b)) => a.id.cmp(&b.id),
(Included::Scrobble(a), Included::Scrobble(b)) => a.id.cmp(&b.id),
(Included::Image(a), Included::Image(b)) => a.id.cmp(&b.id),
(Included::Artist(a), Included::Artist(b)) => a.id.cmp(&b.id),
(Included::Track(a), Included::Track(b)) => a.id.cmp(&b.id),
(Included::Medium(a), Included::Medium(b)) => a.id.cmp(&b.id),
(Included::Release(a), Included::Release(b)) => a.id.cmp(&b.id),
(Included::Genre(a), Included::Genre(b)) => a.id.cmp(&b.id),
(_, _) => std::cmp::Ordering::Less,
}
}
Expand Down
2 changes: 2 additions & 0 deletions server/src/api/internal/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl PartialEq for Included {
match (self, other) {
(Included::Directory(a), Included::Directory(b)) => a.id == b.id,
(Included::Import(a), Included::Import(b)) => a.id == b.id,
(Included::TempoInclude(a), Included::TempoInclude(b)) => a == b,
(_, _) => false,
}
}
Expand All @@ -146,6 +147,7 @@ impl std::cmp::Ord for Included {
match (self, other) {
(Included::Directory(a), Included::Directory(b)) => a.id.cmp(&b.id),
(Included::Import(a), Included::Import(b)) => a.id.cmp(&b.id),
(Included::TempoInclude(a), Included::TempoInclude(b)) => a.cmp(&b),
(_, _) => std::cmp::Ordering::Less,
}
}
Expand Down

0 comments on commit 8b7c33d

Please sign in to comment.