Cleaned up imports.
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::{
|
||||
DecodeError, Delete, QueryConversionError, RepositoryError, Upsert,
|
||||
DecodeError, QueryConversionError, RepositoryError,
|
||||
dtos::{Delete, Upsert},
|
||||
encoding::{
|
||||
decode_direction, decode_recurrence_unit, decode_weekend_adjustment, encode_direction,
|
||||
encode_recurrence_unit, encode_weekend_adjustment,
|
||||
},
|
||||
};
|
||||
use crate::{
|
||||
database::{
|
||||
dtos::recurring_transaction::RecurringTransactionRow, recurring_transactions as db,
|
||||
},
|
||||
database::{dtos::RecurringTransactionRow, recurring_transactions as db},
|
||||
domain::{Cents, Recurrence, RecurrenceInterval, RecurringTransaction, Schedule},
|
||||
};
|
||||
|
||||
@@ -43,7 +42,7 @@ pub async fn query<'e, E>(
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
{
|
||||
let transactions = db::query_recurring_transactions(executor, query.try_into()?)
|
||||
let transactions = db::query(executor, query.try_into()?)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(decode)
|
||||
@@ -59,10 +58,7 @@ pub async fn get<'e, E>(
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
{
|
||||
let transaction = db::get_recurring_transaction_by_id(executor, id)
|
||||
.await?
|
||||
.map(decode)
|
||||
.transpose()?;
|
||||
let transaction = db::get_by_id(executor, id).await?.map(decode).transpose()?;
|
||||
|
||||
Ok(transaction)
|
||||
}
|
||||
@@ -74,18 +70,18 @@ pub async fn upsert<'e, E>(
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
{
|
||||
let transaction = db::upsert_recurring_transaction(executor, encode(transaction))
|
||||
let transaction = db::upsert(executor, encode(transaction))
|
||||
.await?
|
||||
.try_map(decode)?;
|
||||
|
||||
Ok(transaction)
|
||||
Ok(transaction.into())
|
||||
}
|
||||
|
||||
pub async fn delete<'e, E>(executor: E, id: Uuid) -> Result<Delete, RepositoryError>
|
||||
where
|
||||
E: sqlx::Executor<'e, Database = sqlx::Postgres>,
|
||||
{
|
||||
Ok(db::delete_recurring_transaction_by_id(executor, id).await?)
|
||||
Ok(db::delete_by_id(executor, id).await?.into())
|
||||
}
|
||||
|
||||
fn decode(row: RecurringTransactionRow) -> Result<RecurringTransaction, DecodeError> {
|
||||
|
||||
Reference in New Issue
Block a user