Skip to content

Commit 95c5298

Browse files
Resolvers for Processing Jobs
1 parent bbf8660 commit 95c5298

File tree

4 files changed

+68
-5
lines changed

4 files changed

+68
-5
lines changed

.github/workflows/schema.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
run: >
6969
rover subgraph check data-gateway-n63jcf@current
7070
--schema processed_data.graphql
71-
--name processed_data
71+
--name processed-data
7272
env:
7373
APOLLO_KEY: ${{ secrets.APOLLO_STUDIO }}
7474

models/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ const TABLES_SPECS: &[&Table] = &[
3333
"automatic",
3434
],
3535
},
36+
&Table {
37+
name: "ProcessingJobParameter",
38+
columns: &[
39+
"processingJobParameterId",
40+
"processingJobId",
41+
"parameterKey",
42+
"parameterValue",
43+
],
44+
},
3645
&Table {
3746
name: "AutoProc",
3847
columns: &[

processed_data/src/graphql/entities.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use async_graphql::{Enum, SimpleObject};
22
use models::{
33
auto_proc, auto_proc_integration, auto_proc_program, auto_proc_scaling,
44
auto_proc_scaling_statistics, data_collection_file_attachment, processing_job,
5-
sea_orm_active_enums::ScalingStatisticsType,
5+
processing_job_parameter, sea_orm_active_enums::ScalingStatisticsType,
66
};
77

88
/// Represents processed image file stored in s3 bucket
@@ -27,7 +27,7 @@ impl From<data_collection_file_attachment::Model> for DataProcessing {
2727

2828
/// Represents a processing job
2929
#[derive(Clone, Debug, PartialEq, SimpleObject)]
30-
#[graphql(name = "ProcessingJob", unresolvable)]
30+
#[graphql(name = "ProcessingJob", unresolvable, complex)]
3131
pub struct ProcessingJob {
3232
/// An opaque unique identifier for the processing job
3333
pub processing_job_id: u32,
@@ -50,6 +50,28 @@ impl From<processing_job::Model> for ProcessingJob {
5050
}
5151
}
5252

53+
/// Represents a processing job parameters
54+
#[derive(Clone, Debug, PartialEq, SimpleObject)]
55+
#[graphql(name = "ProcessingJobParameter", unresolvable)]
56+
#[allow(clippy::missing_docs_in_private_items)]
57+
pub struct ProcessingJobParameter {
58+
pub processing_job_parameter_id: u32,
59+
pub processing_job_id: Option<u32>,
60+
pub parameter_key: Option<String>,
61+
pub parameter_value: Option<String>,
62+
}
63+
64+
impl From<processing_job_parameter::Model> for ProcessingJobParameter {
65+
fn from(value: processing_job_parameter::Model) -> Self {
66+
Self {
67+
processing_job_id: value.processing_job_id,
68+
processing_job_parameter_id: value.processing_job_parameter_id,
69+
parameter_key: value.parameter_key,
70+
parameter_value: value.parameter_value,
71+
}
72+
}
73+
}
74+
5375
/// Represents an auto processed job
5476
#[derive(Clone, Debug, PartialEq, SimpleObject)]
5577
#[graphql(name = "AutoProc", unresolvable)]

processed_data/src/graphql/mod.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use async_graphql::{
55
ComplexObject, Context, EmptyMutation, EmptySubscription, Object, Schema, SchemaBuilder,
66
};
77
use aws_sdk_s3::presigning::PresigningConfig;
8-
use entities::{DataCollection, DataProcessing};
9-
use models::data_collection_file_attachment;
8+
use entities::{DataCollection, DataProcessing, ProcessingJob, ProcessingJobParameter, AutoProcIntegration};
9+
use models::{data_collection_file_attachment, processing_job, processing_job_parameter, auto_proc_integration};
1010
use sea_orm::{ColumnTrait, DatabaseConnection, EntityTrait, QueryFilter};
1111
use std::time::Duration;
1212
use url::Url;
@@ -39,6 +39,21 @@ impl DataCollection {
3939
.map(DataProcessing::from)
4040
.collect())
4141
}
42+
43+
/// Fetched all the processing jobs
44+
async fn processing_jobs(
45+
&self,
46+
ctx: &Context<'_>,
47+
) -> async_graphql::Result<Vec<ProcessingJob>, async_graphql::Error> {
48+
let database = ctx.data::<DatabaseConnection>()?;
49+
Ok(processing_job::Entity::find()
50+
.filter(processing_job::Column::DataCollectionId.eq(self.id))
51+
.all(database)
52+
.await?
53+
.into_iter()
54+
.map(ProcessingJob::from)
55+
.collect())
56+
}
4257
}
4358

4459
#[ComplexObject]
@@ -60,6 +75,23 @@ impl DataProcessing {
6075
}
6176
}
6277

78+
#[ComplexObject]
79+
impl ProcessingJob {
80+
async fn parameters(
81+
&self,
82+
ctx: &Context<'_>,
83+
) -> async_graphql::Result<Vec<ProcessingJobParameter>> {
84+
let database = ctx.data::<DatabaseConnection>()?;
85+
Ok(processing_job_parameter::Entity::find()
86+
.filter(processing_job_parameter::Column::ProcessingJobId.eq(self.processing_job_id))
87+
.all(database)
88+
.await?
89+
.into_iter()
90+
.map(ProcessingJobParameter::from)
91+
.collect())
92+
}
93+
}
94+
6395
#[Object]
6496
impl Query {
6597
/// Reference datasets resolver for the router

0 commit comments

Comments
 (0)