Added nice chart for account history.

This commit is contained in:
didier amyot committed 2023-04-16 11:34:53 -04:00
1 parent 80153dd6ad
commit e76a521356
14 files changed
+126 -188

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
use crate::db::external_id::{AccountId, Id};
use crate::webui::services::ServicesFactory;
use crate::webui::templates::MiniJinjaRenderer;
use actix_web::{error, web, HttpRequest, Responder, Result};
use serde::Serialize;
struct ResponseData{
}
#[actix_web::get("/data/accounts/{account_id}/amount-history.json")]
pub async fn get_account_amount_history(
account_id: web::Path<String>,
req: HttpRequest,
service_factory: web::Data<ServicesFactory>,
) -> Result<impl Responder> {
let account_id = AccountId::from_string(&account_id.to_string()).unwrap();
let conn = service_factory.get_connection()?;
let auth_service = service_factory.get_authentication_service(&conn)?;
let conn = service_factory.get_connection()?;
let account_service = service_factory.get_account_service(&conn)?;
let user_id = auth_service.get_login(&req).unwrap();
let ac = account_service
.get_account_history_by_id_2(&account_id, &user_id)
.map_err(error::ErrorInternalServerError)?;
Ok(web::Json(ac))
}
+2
View File
@@ -28,6 +28,7 @@ mod templates;
mod views;
mod worker;
mod minininja_utils;
mod data_views;
struct ProductionEventProcessor;
@@ -78,6 +79,7 @@ fn create_views_scope() -> Scope {
.service(views::overview_submit_button)
.service(views::actions_partials)
.service(views::get_accounts_by_security_selectors)
.service(data_views::get_account_amount_history)
}
#[tokio::main]
-3
View File
@@ -46,13 +46,10 @@ pub async fn get_account(tmpl_env: MiniJinjaRenderer,
let ctx = context!{
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)
}
#[actix_web::get("/securities")]
pub async fn securities(tmpl_env: MiniJinjaRenderer,
service_factory: web::Data<ServicesFactory>) -> actix_web::Result<impl Responder> {