Compare commits
No commits in common. "a3a4ae8ca4816f0705110204b722c763dcc3e3a4" and "de5d256c9622af173b5c316478112338ec1e8483" have entirely different histories.
a3a4ae8ca4
...
de5d256c96
|
@ -90,12 +90,8 @@ pub enum SnapshotSubcommands {
|
||||||
/// Show a snapshot.
|
/// Show a snapshot.
|
||||||
Show {
|
Show {
|
||||||
/// The date of the snapshot to show, defaults to today.
|
/// The date of the snapshot to show, defaults to today.
|
||||||
#[clap(short, long, group = "selection")]
|
#[clap(short, long)]
|
||||||
date: Option<NaiveDate>,
|
date: Option<NaiveDate>,
|
||||||
|
|
||||||
/// The ID of the snapshot to show.
|
|
||||||
#[clap(long, group = "selection")]
|
|
||||||
id: Option<i64>,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,27 +58,18 @@ pub async fn run() -> Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SnapshotSubcommands::Show { date, id } => {
|
SnapshotSubcommands::Show { date } => {
|
||||||
let date = date.unwrap_or_else(today);
|
let date = date.unwrap_or_else(today);
|
||||||
|
let snapshot = if let Some(snapshot) =
|
||||||
let snapshot = match id {
|
SnapshotModel::get_by_date(&db, date).await?
|
||||||
Some(id) => SnapshotModel::get_by_id(&db, id).await,
|
{
|
||||||
None => SnapshotModel::get_by_date(&db, date).await,
|
info!("Snapshot {snapshot:?}");
|
||||||
}?;
|
snapshot
|
||||||
|
} else {
|
||||||
let snapshot = match (snapshot, id) {
|
info!("No snapshot exists for {date}");
|
||||||
(None, Some(id)) => {
|
return Ok(());
|
||||||
info!("No snapshot exists for id {id}");
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
(None, None) => {
|
|
||||||
info!("No snapshot exists for date {date}");
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
(Some(snapshot), _) => snapshot,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Snapshot {snapshot:?}");
|
|
||||||
for group in GroupDataModel::get_all_by_snapshot(&db, &snapshot).await?
|
for group in GroupDataModel::get_all_by_snapshot(&db, &snapshot).await?
|
||||||
{
|
{
|
||||||
info!(
|
info!(
|
||||||
|
|
|
@ -27,19 +27,6 @@ impl SnapshotModel {
|
||||||
Ok(existing)
|
Ok(existing)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a snapshot by a given ID.
|
|
||||||
pub async fn get_by_id(
|
|
||||||
db: &DatabaseConnection,
|
|
||||||
id: i64,
|
|
||||||
) -> Result<Option<Self>> {
|
|
||||||
let snapshot = SnapshotEntity::find()
|
|
||||||
.filter(SnapshotColumn::Id.eq(id))
|
|
||||||
.one(db)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(snapshot)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get all snapshots.
|
/// Get all snapshots.
|
||||||
pub async fn get_all(db: &DatabaseConnection) -> Result<Vec<Self>> {
|
pub async fn get_all(db: &DatabaseConnection) -> Result<Vec<Self>> {
|
||||||
let snapshots = SnapshotEntity::find().all(db).await?;
|
let snapshots = SnapshotEntity::find().all(db).await?;
|
||||||
|
|
Loading…
Reference in New Issue