Skip to content

Commit 8b7c33d

Browse files
committed
fix deduplication of included entities
Closes #3
1 parent af2aca7 commit 8b7c33d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

server/src/api/documents.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,14 @@ pub enum Included {
6565
impl PartialEq for Included {
6666
fn eq(&self, other: &Self) -> bool {
6767
match (self, other) {
68+
(Included::User(a), Included::User(b)) => a.id == b.id,
69+
(Included::Scrobble(a), Included::Scrobble(b)) => a.id == b.id,
6870
(Included::Image(a), Included::Image(b)) => a.id == b.id,
6971
(Included::Artist(a), Included::Artist(b)) => a.id == b.id,
7072
(Included::Track(a), Included::Track(b)) => a.id == b.id,
7173
(Included::Medium(a), Included::Medium(b)) => a.id == b.id,
7274
(Included::Release(a), Included::Release(b)) => a.id == b.id,
75+
(Included::Genre(a), Included::Genre(b)) => a.id == b.id,
7376
(_, _) => false,
7477
}
7578
}
@@ -85,11 +88,14 @@ impl std::cmp::PartialOrd for Included {
8588
impl std::cmp::Ord for Included {
8689
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
8790
match (self, other) {
91+
(Included::User(a), Included::User(b)) => a.id.cmp(&b.id),
92+
(Included::Scrobble(a), Included::Scrobble(b)) => a.id.cmp(&b.id),
8893
(Included::Image(a), Included::Image(b)) => a.id.cmp(&b.id),
8994
(Included::Artist(a), Included::Artist(b)) => a.id.cmp(&b.id),
9095
(Included::Track(a), Included::Track(b)) => a.id.cmp(&b.id),
9196
(Included::Medium(a), Included::Medium(b)) => a.id.cmp(&b.id),
9297
(Included::Release(a), Included::Release(b)) => a.id.cmp(&b.id),
98+
(Included::Genre(a), Included::Genre(b)) => a.id.cmp(&b.id),
9399
(_, _) => std::cmp::Ordering::Less,
94100
}
95101
}

server/src/api/internal/documents.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ impl PartialEq for Included {
129129
match (self, other) {
130130
(Included::Directory(a), Included::Directory(b)) => a.id == b.id,
131131
(Included::Import(a), Included::Import(b)) => a.id == b.id,
132+
(Included::TempoInclude(a), Included::TempoInclude(b)) => a == b,
132133
(_, _) => false,
133134
}
134135
}
@@ -146,6 +147,7 @@ impl std::cmp::Ord for Included {
146147
match (self, other) {
147148
(Included::Directory(a), Included::Directory(b)) => a.id.cmp(&b.id),
148149
(Included::Import(a), Included::Import(b)) => a.id.cmp(&b.id),
150+
(Included::TempoInclude(a), Included::TempoInclude(b)) => a.cmp(&b),
149151
(_, _) => std::cmp::Ordering::Less,
150152
}
151153
}

0 commit comments

Comments
 (0)