mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
database: Fix some clippy warnings
This commit is contained in:
parent
f967f6ade9
commit
2b95dbeadd
3 changed files with 43 additions and 47 deletions
|
|
@ -267,10 +267,8 @@ impl Database {
|
||||||
|
|
||||||
for part_index in work_parts {
|
for part_index in work_parts {
|
||||||
if !part_index.is_empty() {
|
if !part_index.is_empty() {
|
||||||
let index = str::parse(part_index).or(Err(Error::ParsingError(
|
let index = str::parse(part_index)
|
||||||
"part index",
|
.map_err(|_| Error::ParsingError("part index", String::from(part_index)))?;
|
||||||
String::from(part_index),
|
|
||||||
)))?;
|
|
||||||
|
|
||||||
part_indices.push(index);
|
part_indices.push(index);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,11 @@ impl Performance {
|
||||||
/// Get a string representation of the performance.
|
/// Get a string representation of the performance.
|
||||||
// TODO: Replace with impl Display.
|
// TODO: Replace with impl Display.
|
||||||
pub fn get_title(&self) -> String {
|
pub fn get_title(&self) -> String {
|
||||||
let mut text = String::from(if self.is_person() {
|
let mut text = if self.is_person() {
|
||||||
self.unwrap_person().name_fl()
|
self.unwrap_person().name_fl()
|
||||||
} else {
|
} else {
|
||||||
self.unwrap_ensemble().name
|
self.unwrap_ensemble().name
|
||||||
});
|
};
|
||||||
|
|
||||||
if self.has_role() {
|
if self.has_role() {
|
||||||
text = text + " (" + &self.unwrap_role().name + ")";
|
text = text + " (" + &self.unwrap_role().name + ")";
|
||||||
|
|
@ -249,7 +249,7 @@ impl Database {
|
||||||
let recording_description = Recording {
|
let recording_description = Recording {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
work,
|
work,
|
||||||
comment: row.comment.clone(),
|
comment: row.comment,
|
||||||
performances: performance_descriptions,
|
performances: performance_descriptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,51 +130,49 @@ impl Database {
|
||||||
.values(row)
|
.values(row)
|
||||||
.execute(&self.connection)?;
|
.execute(&self.connection)?;
|
||||||
|
|
||||||
match work {
|
let Work {
|
||||||
Work {
|
instruments,
|
||||||
instruments,
|
parts,
|
||||||
parts,
|
sections,
|
||||||
sections,
|
..
|
||||||
..
|
} = work;
|
||||||
} => {
|
|
||||||
for instrument in instruments {
|
|
||||||
let row = InstrumentationRow {
|
|
||||||
id: rand::random(),
|
|
||||||
work: work_id.to_string(),
|
|
||||||
instrument: instrument.id,
|
|
||||||
};
|
|
||||||
|
|
||||||
diesel::insert_into(instrumentations::table)
|
for instrument in instruments {
|
||||||
.values(row)
|
let row = InstrumentationRow {
|
||||||
.execute(&self.connection)?;
|
id: rand::random(),
|
||||||
}
|
work: work_id.to_string(),
|
||||||
|
instrument: instrument.id,
|
||||||
|
};
|
||||||
|
|
||||||
for (index, part) in parts.into_iter().enumerate() {
|
diesel::insert_into(instrumentations::table)
|
||||||
let row = WorkPartRow {
|
.values(row)
|
||||||
id: rand::random(),
|
.execute(&self.connection)?;
|
||||||
work: work_id.to_string(),
|
}
|
||||||
part_index: index as i64,
|
|
||||||
title: part.title,
|
|
||||||
};
|
|
||||||
|
|
||||||
diesel::insert_into(work_parts::table)
|
for (index, part) in parts.into_iter().enumerate() {
|
||||||
.values(row)
|
let row = WorkPartRow {
|
||||||
.execute(&self.connection)?;
|
id: rand::random(),
|
||||||
}
|
work: work_id.to_string(),
|
||||||
|
part_index: index as i64,
|
||||||
|
title: part.title,
|
||||||
|
};
|
||||||
|
|
||||||
for section in sections {
|
diesel::insert_into(work_parts::table)
|
||||||
let row = WorkSectionRow {
|
.values(row)
|
||||||
id: rand::random(),
|
.execute(&self.connection)?;
|
||||||
work: work_id.to_string(),
|
}
|
||||||
title: section.title,
|
|
||||||
before_index: section.before_index as i64,
|
|
||||||
};
|
|
||||||
|
|
||||||
diesel::insert_into(work_sections::table)
|
for section in sections {
|
||||||
.values(row)
|
let row = WorkSectionRow {
|
||||||
.execute(&self.connection)?;
|
id: rand::random(),
|
||||||
}
|
work: work_id.to_string(),
|
||||||
}
|
title: section.title,
|
||||||
|
before_index: section.before_index as i64,
|
||||||
|
};
|
||||||
|
|
||||||
|
diesel::insert_into(work_sections::table)
|
||||||
|
.values(row)
|
||||||
|
.execute(&self.connection)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue