Added account history in the ui.
This commit is contained in:
1 parent
f4593df95b
commit
18e7b0df1c
5 files changed
+78
-10
No files matched your search
@@ -24,7 +24,7 @@ impl AccountHistory {
|
||||
|
||||
pub fn get_account_history(tx: &Connection, account_id: &AccountId) -> CustomResult<AccountHistory> {
|
||||
let q = "
|
||||
SELECT amount, CAST(timestamp AS INT) AS timestamp
|
||||
SELECT amount, UNIXEPOCH(timestamp) AS timestamp
|
||||
FROM accounts_history
|
||||
WHERE account_id = ?1
|
||||
ORDER BY account_version ASC
|
||||
|
||||
@@ -22,9 +22,10 @@ pub struct AccountDTO {
|
||||
pub label: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct AccountHistoryDTO {
|
||||
|
||||
amounts: Vec<i64>,
|
||||
timestamps: Vec<i64>,
|
||||
}
|
||||
|
||||
impl AccountDTO {
|
||||
@@ -72,9 +73,14 @@ impl AccountService<'_> {
|
||||
Ok(AccountDTO::from_entity(ret))
|
||||
}
|
||||
|
||||
pub fn get_account_history_by_id(&self, account_id: &AccountId, user_id: &UserId) -> CustomResult<()> {
|
||||
let ret = account_history::get_account_history(self.conn, account_id)?;
|
||||
pub fn get_account_history_by_id(&self, account_id: &AccountId, user_id: &UserId) -> CustomResult<AccountHistoryDTO> {
|
||||
let ac = account_history::get_account_history(self.conn, account_id)?;
|
||||
// ret.account()
|
||||
let ret = AccountHistoryDTO{
|
||||
amounts: ac.amount().clone(),
|
||||
timestamps: ac.timestamps().clone(),
|
||||
};
|
||||
|
||||
Ok(())
|
||||
Ok(ret)
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -45,7 +45,8 @@ pub async fn get_account(tmpl_env: MiniJinjaRenderer,
|
||||
let user_id = auth_service.get_login(&req).unwrap();
|
||||
|
||||
let ctx = context!{
|
||||
account => account_service.get_account_by_id(&account_id, &user_id).map_err(error::ErrorInternalServerError)?
|
||||
account => account_service.get_account_by_id(&account_id, &user_id).map_err(error::ErrorInternalServerError)?,
|
||||
account_history => account_service.get_account_history_by_id(&account_id, &user_id).map_err(error::ErrorInternalServerError)?
|
||||
};
|
||||
tmpl_env.render("account.html", ctx)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user