aboutsummaryrefslogtreecommitdiff
path: root/src/jobs
diff options
context:
space:
mode:
authorJoris2023-04-17 21:10:48 +0200
committerJoris2023-04-17 21:10:48 +0200
commit459016e70dd4933a8082d27748097de81a3e53ff (patch)
tree0ed14ecc8762d62a55bf8c05356bcc984b1a0cea /src/jobs
parent3932daa26360d6e03807381d0b8ffa2d0e704847 (diff)
Follow clippy indications
Diffstat (limited to 'src/jobs')
-rw-r--r--src/jobs/jobs.rs28
-rw-r--r--src/jobs/mod.rs29
2 files changed, 28 insertions, 29 deletions
diff --git a/src/jobs/jobs.rs b/src/jobs/jobs.rs
deleted file mode 100644
index 536ff97..0000000
--- a/src/jobs/jobs.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use sqlx::sqlite::SqlitePool;
-use tera::Tera;
-use tokio::time::{sleep, Duration};
-
-use crate::db;
-use crate::jobs::weekly_report;
-use crate::model::config::Config;
-use crate::model::job::Job;
-
-pub async fn start(config: Config, pool: SqlitePool, templates: Tera) -> () {
- loop {
- if db::jobs::should_run(&pool, Job::WeeklyReport).await {
- info!("Starting weekly report job");
- if weekly_report::send(&config, &pool, &templates).await {
- db::jobs::actualize_last_execution(&pool, Job::WeeklyReport)
- .await;
- }
- }
- if db::jobs::should_run(&pool, Job::MonthlyPayment).await {
- info!("Starting monthly payment job");
- db::payments::create_monthly_payments(&pool).await;
- db::jobs::actualize_last_execution(&pool, Job::MonthlyPayment)
- .await;
- }
- // Sleeping 8 hours
- sleep(Duration::from_secs(8 * 60 * 60)).await;
- }
-}
diff --git a/src/jobs/mod.rs b/src/jobs/mod.rs
index be2ddac..5f95597 100644
--- a/src/jobs/mod.rs
+++ b/src/jobs/mod.rs
@@ -1,2 +1,29 @@
-pub mod jobs;
mod weekly_report;
+
+use sqlx::sqlite::SqlitePool;
+use tera::Tera;
+use tokio::time::{sleep, Duration};
+
+use crate::db;
+use crate::model::config::Config;
+use crate::model::job::Job;
+
+pub async fn start(config: Config, pool: SqlitePool, templates: Tera) {
+ loop {
+ if db::jobs::should_run(&pool, Job::WeeklyReport).await {
+ info!("Starting weekly report job");
+ if weekly_report::send(&config, &pool, &templates).await {
+ db::jobs::actualize_last_execution(&pool, Job::WeeklyReport)
+ .await;
+ }
+ }
+ if db::jobs::should_run(&pool, Job::MonthlyPayment).await {
+ info!("Starting monthly payment job");
+ db::payments::create_monthly_payments(&pool).await;
+ db::jobs::actualize_last_execution(&pool, Job::MonthlyPayment)
+ .await;
+ }
+ // Sleeping 8 hours
+ sleep(Duration::from_secs(8 * 60 * 60)).await;
+ }
+}