Skip to content

Commit

Permalink
chore: run formatter for all changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jooakar committed Feb 1, 2024
1 parent 7e58a99 commit 7cd1055
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
7 changes: 2 additions & 5 deletions src/api/invoices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ pub async fn create(
}

pub async fn list_all(
mut conn: DatabaseConnection
mut conn: DatabaseConnection,
) -> Result<(StatusCode, Json<Vec<PopulatedInvoice>>), Error> {
Ok((
StatusCode::OK,
axum::Json(conn.list_invoices().await?),
))
Ok((StatusCode::OK, axum::Json(conn.list_invoices().await?)))
}
23 changes: 10 additions & 13 deletions src/database/invoices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ impl DatabaseConnection {
}
pub async fn list_invoices(&mut self) -> Result<Vec<PopulatedInvoice>, Error> {
let (invoices, parties): (Vec<Invoice>, Vec<Party>) = {
use crate::schema::parties;
use crate::schema::invoices;
use crate::schema::parties;
invoices::table
.inner_join(parties::table)
.select((Invoice::as_select(), Party::as_select()))
Expand All @@ -130,18 +130,15 @@ impl DatabaseConnection {
.zip(attachments)
.zip(invoices)
.zip(parties)
.map(|(((rows, attachments), invoice), party)| {
PopulatedInvoice {
id: invoice.id,
status: invoice.status,
creation_time: invoice.creation_time,
counter_party: party,
rows,
due_date: invoice.due_date,
attachments,
}
.map(|(((rows, attachments), invoice), party)| PopulatedInvoice {
id: invoice.id,
status: invoice.status,
creation_time: invoice.creation_time,
counter_party: party,
rows,
due_date: invoice.due_date,
attachments,
})
.collect::<Vec<PopulatedInvoice>>()
)
.collect::<Vec<PopulatedInvoice>>())
}
}
2 changes: 1 addition & 1 deletion src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::schema::{invoice_attachments, invoice_rows, invoices, parties};
use chrono::{DateTime, NaiveDate, Utc};
use garde::Validate;

use serde_derive::{Deserialize, Serialize};
use diesel::prelude::*;
use serde_derive::{Deserialize, Serialize};

// NOTES:
// This is implemented based on https://github.com/Tietokilta/laskugeneraattori/blob/main/backend/src/procountor.rs#L293
Expand Down

0 comments on commit 7cd1055

Please sign in to comment.