mirror of
https://github.com/johrpan/wolfgang.git
synced 2025-10-26 02:37:25 +01:00
Remove separate part composers
This commit is contained in:
parent
59acc460f8
commit
c0cfb1abfe
3 changed files with 1 additions and 21 deletions
|
|
@ -37,8 +37,7 @@ CREATE TABLE work_parts (
|
|||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
work TEXT NOT NULL REFERENCES works(id) ON DELETE CASCADE,
|
||||
part_index BIGINT NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
composer TEXT REFERENCES persons(id)
|
||||
title TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE work_sections (
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ table! {
|
|||
work -> Text,
|
||||
part_index -> Int8,
|
||||
title -> Text,
|
||||
composer -> Nullable<Text>,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +130,6 @@ joinable!(recordings -> works (work));
|
|||
joinable!(track_sets -> mediums (medium));
|
||||
joinable!(track_sets -> recordings (recording));
|
||||
joinable!(tracks -> track_sets (track_set));
|
||||
joinable!(work_parts -> persons (composer));
|
||||
joinable!(work_parts -> works (work));
|
||||
joinable!(work_sections -> works (work));
|
||||
joinable!(works -> persons (composer));
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ pub struct Work {
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct WorkPart {
|
||||
pub title: String,
|
||||
pub composer: Option<Person>,
|
||||
}
|
||||
|
||||
/// A heading within the work structure.
|
||||
|
|
@ -62,7 +61,6 @@ struct WorkPartRow {
|
|||
pub work: String,
|
||||
pub part_index: i64,
|
||||
pub title: String,
|
||||
pub composer: Option<String>,
|
||||
}
|
||||
|
||||
/// Table data for a work section.
|
||||
|
|
@ -106,14 +104,6 @@ pub fn update_work(conn: &DbConn, work: &Work, user: &User) -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
for part in &work.parts {
|
||||
if let Some(person) = &part.composer {
|
||||
if get_person(conn, &person.id)?.is_none() {
|
||||
update_person(conn, person, &user)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the actual work.
|
||||
|
||||
let row = WorkRow {
|
||||
|
|
@ -143,7 +133,6 @@ pub fn update_work(conn: &DbConn, work: &Work, user: &User) -> Result<()> {
|
|||
work: id.clone(),
|
||||
part_index: index.try_into()?,
|
||||
title: part.title.clone(),
|
||||
composer: part.composer.as_ref().map(|person| person.id.clone()),
|
||||
};
|
||||
|
||||
diesel::insert_into(work_parts::table)
|
||||
|
|
@ -242,12 +231,6 @@ fn get_description_for_work_row(conn: &DbConn, row: &WorkRow) -> Result<Work> {
|
|||
for part_row in part_rows {
|
||||
parts.push(WorkPart {
|
||||
title: part_row.title,
|
||||
composer: match part_row.composer {
|
||||
Some(id) => {
|
||||
Some(get_person(conn, &id)?.ok_or(anyhow!("No person with ID: {}", id))?)
|
||||
}
|
||||
None => None,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue