feat(domain): add StoredSong, SongSummary, SongRepositoryPort

This commit is contained in:
2026-04-08 03:03:58 +02:00
parent 852b1a8d0e
commit 8f9886c9a9
4 changed files with 56 additions and 1 deletions

View File

@@ -60,6 +60,40 @@ pub struct Song {
pub sections: Vec<Section>,
}
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StoredSong {
pub id: Uuid,
pub song: Song,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SongSummary {
pub id: Uuid,
pub meta: SongMeta,
pub preview_chords: Vec<String>,
}
pub fn song_preview_chords(song: &Song) -> Vec<String> {
let mut seen = std::collections::HashSet::new();
let mut result = Vec::new();
'outer: for section in &song.sections {
for line in &section.lines {
for cp in &line.chords {
let name = cp.chord.name(true);
if seen.insert(name.clone()) {
result.push(name);
if result.len() >= 5 {
break 'outer;
}
}
}
}
}
result
}
#[cfg(test)]
mod tests {
use super::*;