aboutsummaryrefslogtreecommitdiff
path: root/common/src/lib.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-08-07 13:46:22 +0200
committermetamuffin <metamuffin@disroot.org>2023-08-07 13:46:22 +0200
commita2e557e648cf253d47e9f4b9dd99ee657610f294 (patch)
tree350fe5868c9f7d890c79b2489b307c263ed7c307 /common/src/lib.rs
parent908db5458b07d7a13f24c755d340ab3c1917e8a8 (diff)
downloadjellything-a2e557e648cf253d47e9f4b9dd99ee657610f294.tar
jellything-a2e557e648cf253d47e9f4b9dd99ee657610f294.tar.bz2
jellything-a2e557e648cf253d47e9f4b9dd99ee657610f294.tar.zst
extend sort and filter
Diffstat (limited to 'common/src/lib.rs')
-rw-r--r--common/src/lib.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/common/src/lib.rs b/common/src/lib.rs
index 9d5a31e..b02f58c 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -4,12 +4,14 @@
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
pub mod config;
+pub mod helpers;
pub mod r#impl;
use bincode::{Decode, Encode};
+#[cfg(feature = "rocket")]
use rocket::{FromFormField, UriDisplayQuery};
use serde::{Deserialize, Serialize};
-use std::path::PathBuf;
+use std::{collections::BTreeMap, path::PathBuf};
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Node {
@@ -38,7 +40,7 @@ pub struct NodePublic {
#[serde(default)] pub description: Option<String>,
#[serde(default)] pub index: Option<usize>,
#[serde(default)] pub media: Option<MediaInfo>,
- #[serde(default)] pub ratings: Vec<Rating>,
+ #[serde(default)] pub ratings: BTreeMap<Rating, f64>,
#[serde(default)] pub federated: Option<String>,
}
@@ -107,15 +109,15 @@ pub struct SourceTrack {
pub default_duration: Option<u64>,
}
-#[derive(Debug, Clone, Deserialize, Serialize)]
+#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, PartialOrd, Ord)]
#[serde(rename_all = "snake_case")]
pub enum Rating {
- RottenTomatoes(u8),
- Metacritic(u8),
- Imdb(f32),
- YoutubeViews(usize),
- YoutubeLikes(usize),
- YoutubeFollowers(usize),
+ RottenTomatoes,
+ Metacritic,
+ Imdb,
+ YoutubeViews,
+ YoutubeLikes,
+ YoutubeFollowers,
}
#[derive(Debug, Clone, Deserialize, Serialize)]