Skip to content

Commit

Permalink
build: linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Jul 23, 2024
1 parent 55e1bc8 commit 9d7ab21
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## Added

- creation of data submission jobs.

## Changed
Expand Down
3 changes: 1 addition & 2 deletions crates/orchestrator/src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ pub trait Database: Send + Sync {
) -> Result<Vec<JobItem>>;

// TODO: can be extendible to support multiple status.
async fn get_jobs_by_status(&self, status : JobStatus ) -> Result<Vec<JobItem>>;

async fn get_jobs_by_status(&self, status: JobStatus) -> Result<Vec<JobItem>>;
}

pub trait DatabaseConfig {
Expand Down
11 changes: 5 additions & 6 deletions crates/orchestrator/src/database/mongodb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,16 @@ impl Database for MongoDb {
Ok(results)
}

async fn get_jobs_by_status(&self, job_status : JobStatus) -> Result<Vec<JobItem>> {

async fn get_jobs_by_status(&self, job_status: JobStatus) -> Result<Vec<JobItem>> {
let filter = doc! {
"job_status": bson::to_bson(&job_status)?
};

let mut jobs = self
.get_job_collection()
.find(filter, None)
.await
.expect("Failed to fetch jobs by given job type and status");
.get_job_collection()
.find(filter, None)
.await
.expect("Failed to fetch jobs by given job type and status");

let mut results = Vec::new();

Expand Down
2 changes: 1 addition & 1 deletion crates/orchestrator/src/jobs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub async fn verify_job(id: Uuid) -> Result<()> {
JobVerificationStatus::Verified => {
config.database().update_job_status(&job, JobStatus::Completed).await?;
}
JobVerificationStatus::Rejected(_) => {
JobVerificationStatus::Rejected(_) => {
// TODO: change '_' to 'e' and add error 'e' to metadata of job status.
config.database().update_job_status(&job, JobStatus::VerificationFailed).await?;

Expand Down
12 changes: 3 additions & 9 deletions crates/orchestrator/src/workers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::error::Error;
use crate::{config::config, jobs::types::JobStatus};
use async_trait::async_trait;
use std::error::Error;

pub mod data_submission;
pub mod proof_registration;
Expand All @@ -10,7 +10,6 @@ pub mod update_state;

#[async_trait]
pub trait Worker: Send + Sync {

async fn run_worker_if_enabled(&self) -> Result<(), Box<dyn Error>> {
if !self.is_worker_enabled().await? {
return Ok(());
Expand All @@ -29,14 +28,9 @@ pub trait Worker: Send + Sync {
async fn is_worker_enabled(&self) -> Result<bool, Box<dyn Error>> {
let config = config().await;

let failed_da_jobs = config
.database()
.get_jobs_by_status(
JobStatus::VerificationFailed,
)
.await?;
let failed_da_jobs = config.database().get_jobs_by_status(JobStatus::VerificationFailed).await?;

if failed_da_jobs.len() > 0 {
if !failed_da_jobs.is_empty() {
return Ok(false);
}

Expand Down

0 comments on commit 9d7ab21

Please sign in to comment.