-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#22 Implement absolute plots for albums and songs
- Loading branch information
Showing
5 changed files
with
70 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
use super::{create_plot, find_dates}; | ||
use crate::display::date; | ||
use crate::types::{Artist, SongEntries}; | ||
use crate::types::{Music, SongEntries}; | ||
|
||
/// Creates a plot of the absolute amount of plays of an [`Artist`] | ||
/// Creates a plot of the absolute amount of plays | ||
/// | ||
/// Opens the plot in the browser | ||
pub fn artist(entries: &SongEntries, art: &Artist) { | ||
pub fn aspect<Asp: Music>(entries: &SongEntries, aspect: &Asp) { | ||
let mut times = Vec::<i64>::new(); | ||
let mut plays = Vec::<usize>::new(); | ||
|
||
let dates = find_dates(entries, art, true); | ||
let dates = find_dates(entries, aspect, true); | ||
|
||
let start = dates.first().unwrap(); | ||
|
||
for date in &dates { | ||
times.push(date.timestamp()); | ||
plays.push(date::gather_plays(entries, art, start, date)); | ||
plays.push(date::gather_plays(entries, aspect, start, date)); | ||
} | ||
|
||
create_plot(times, plays, art.name.as_str()); | ||
let title = format!("{aspect}"); | ||
create_plot(times, plays, &title); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters