Skip to content

Commit

Permalink
pass plex_filename.{collection_id, music_collection_id}
Browse files Browse the repository at this point in the history
  • Loading branch information
ddboline committed Sep 10, 2024
1 parent 2821f7c commit 59a0acf
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion movie_collection_http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ postgres-types = "0.2"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
reqwest = {version="0.12", features=["cookies", "json", "rustls-tls"], default_features=false}
reqwest = {version="0.12", features=["cookies", "json", "rustls-tls"], default-features=false}
rust_decimal = {version="1.27", features=["db-tokio-postgres"]}
rust_decimal_macros = "1.27"
rweb = {git = "https://github.com/ddboline/rweb.git", features=["openapi"], default-features=false, tag="0.15.2"}
Expand Down
2 changes: 2 additions & 0 deletions movie_collection_http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ struct _PlexFilenameWrapper {
filename: StackString,
#[schema(description = "Collection Id")]
collection_id: Option<UuidWrapper>,
#[schema(description = "Music Collection Id")]
music_collection_id: Option<UuidWrapper>,
}

#[derive(Default, Debug, Serialize, Deserialize, Into, From, Deref)]
Expand Down
2 changes: 1 addition & 1 deletion movie_collection_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ postgres-types = "0.2"
procfs = "0.16"
rand = "0.8"
rayon = "1.5"
reqwest = {version="0.12", features=["cookies", "json", "rustls-tls"], default_features=false}
reqwest = {version="0.12", features=["cookies", "json", "rustls-tls"], default-features=false}
roxmltree = "0.20"
rust_decimal = {version="1.27", features=["db-tokio-postgres"]}
select = "0.6"
Expand Down
35 changes: 35 additions & 0 deletions movie_collection_lib/src/plex_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ impl PlexEvent {
metadata_key: metadata_key.clone(),
filename,
collection_id: None,
music_collection_id: None,
})
}

Expand Down Expand Up @@ -487,6 +488,7 @@ pub struct PlexFilename {
pub metadata_key: StackString,
pub filename: StackString,
pub collection_id: Option<Uuid>,
pub music_collection_id: Option<Uuid>,
}

impl PlexFilename {
Expand Down Expand Up @@ -577,11 +579,43 @@ impl PlexFilename {
.is_none()
{
self._insert(&conn).await?;
} else {
self._update(&conn).await?;
}
tran.commit().await?;
Ok(())
}

async fn _update<C>(&self, conn: &C) -> Result<(), Error>
where C: GenericClient + Sync
{
if self.collection_id.is_some() {
let query = query!(
"
UPDATE plex_filename
SET collection_id=$collection_id
WHERE metadata_key=$metadata_key
",
collection_id=self.collection_id,
metadata_key=self.metadata_key,
);
query.execute(&conn).await?;
}
if self.music_collection_id.is_some() {
let query = query!(
"
UPDATE plex_filename
SET music_collection_id=$music_collection_id
WHERE metadata_key=$metadata_key
",
music_collection_id=self.music_collection_id,
metadata_key=self.metadata_key,
);
query.execute(&conn).await?;
}
Ok(())
}

/// # Errors
/// Return error if db query fails
pub async fn delete(&self, pool: &PgPool) -> Result<(), Error> {
Expand Down Expand Up @@ -1007,6 +1041,7 @@ impl PlexMetadata {
metadata_key: plex_metadata.metadata_key.clone(),
filename: f.into(),
collection_id: None,
music_collection_id: None,
});
Ok(Some((plex_metadata, plex_filename)))
})
Expand Down
2 changes: 1 addition & 1 deletion transcode_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ edition = "2018"
anyhow = "1.0"
deadpool = "0.12"
deadpool-lapin = {version="0.12", features=["serde"]}
lapin = {version="2.0", default_features=false, features=["rustls"]}
lapin = {version="2.0", default-features=false, features=["rustls"]}
derive_more = "0.99"
futures = "0.3"
log = "0.4"
Expand Down

0 comments on commit 59a0acf

Please sign in to comment.