@@ -6,12 +6,13 @@ use async_graphql::{
66} ;
77use aws_sdk_s3:: presigning:: PresigningConfig ;
88use entities:: {
9- AutoProcIntegration , DataCollection , DataProcessing , ProcessingJob , ProcessingJobParameter ,
10- AutoProc , AutoProcScaling ,
9+ AutoProc , AutoProcIntegration , AutoProcScaling , AutoProcScalingStatics , DataCollection ,
10+ DataProcessing , ProcessingJob , ProcessingJobParameter ,
1111} ;
1212use models:: {
13- auto_proc_integration, auto_proc_program, data_collection_file_attachment, processing_job,
14- processing_job_parameter, auto_proc, auto_proc_scaling,
13+ auto_proc, auto_proc_integration, auto_proc_program, auto_proc_scaling,
14+ auto_proc_scaling_statistics, data_collection_file_attachment, processing_job,
15+ processing_job_parameter,
1516} ;
1617use sea_orm:: { ColumnTrait , DatabaseConnection , EntityTrait , QueryFilter } ;
1718use std:: time:: Duration ;
@@ -62,6 +63,21 @@ impl DataCollection {
6263 . map ( ProcessingJob :: from)
6364 . collect ( ) )
6465 }
66+
67+ /// Fetches all the automatic process
68+ async fn auto_proc_integration (
69+ & self ,
70+ ctx : & Context < ' _ > ,
71+ ) -> async_graphql:: Result < Vec < AutoProcIntegration > , async_graphql:: Error > {
72+ let database = ctx. data :: < DatabaseConnection > ( ) ?;
73+ Ok ( auto_proc_integration:: Entity :: find ( )
74+ . filter ( auto_proc_integration:: Column :: DataCollectionId . eq ( self . id ) )
75+ . all ( database)
76+ . await ?
77+ . into_iter ( )
78+ . map ( AutoProcIntegration :: from)
79+ . collect ( ) )
80+ }
6581}
6682
6783#[ ComplexObject ]
@@ -85,6 +101,7 @@ impl DataProcessing {
85101
86102#[ ComplexObject ]
87103impl ProcessingJob {
104+ /// Fetches the processing job parameters
88105 async fn parameters (
89106 & self ,
90107 ctx : & Context < ' _ > ,
@@ -102,6 +119,7 @@ impl ProcessingJob {
102119
103120#[ ComplexObject ]
104121impl AutoProcIntegration {
122+ /// Fetches the automatically processed programs
105123 async fn auto_proc_program (
106124 & self ,
107125 ctx : & Context < ' _ > ,
@@ -119,14 +137,46 @@ impl AutoProcIntegration {
119137
120138#[ ComplexObject ]
121139impl AutoProcProgram {
122- async fn auto_proc ( & self , ctx : & Context < ' _ > , ) -> async_graphql:: Result < Option < AutoProc > > {
140+ /// Fetched the automatic process
141+ async fn auto_proc ( & self , ctx : & Context < ' _ > ) -> async_graphql:: Result < Option < AutoProc > > {
123142 let database = ctx. data :: < DatabaseConnection > ( ) ?;
124143 Ok ( auto_proc:: Entity :: find ( )
125144 . filter ( auto_proc:: Column :: AutoProcProgramId . eq ( self . auto_proc_program_id ) )
126145 . one ( database)
127146 . await ?
128- . map ( AutoProc :: from)
147+ . map ( AutoProc :: from) )
148+ }
149+ }
150+
151+ #[ ComplexObject ]
152+ impl AutoProc {
153+ /// Fetches the scaling for automatic process
154+ async fn scaling ( & self , ctx : & Context < ' _ > ) -> async_graphql:: Result < Option < AutoProcScaling > > {
155+ let database = ctx. data :: < DatabaseConnection > ( ) ?;
156+ Ok ( auto_proc_scaling:: Entity :: find ( )
157+ . filter ( auto_proc_scaling:: Column :: AutoProcId . eq ( self . auto_proc_id ) )
158+ . one ( database)
159+ . await ?
160+ . map ( AutoProcScaling :: from) )
161+ }
162+ }
163+
164+ #[ ComplexObject ]
165+ impl AutoProcScaling {
166+ /// Fetches the scaling statistics
167+ async fn statistics (
168+ & self ,
169+ ctx : & Context < ' _ > ,
170+ ) -> async_graphql:: Result < Option < AutoProcScalingStatics > > {
171+ let database = ctx. data :: < DatabaseConnection > ( ) ?;
172+ Ok ( auto_proc_scaling_statistics:: Entity :: find ( )
173+ . filter (
174+ auto_proc_scaling_statistics:: Column :: AutoProcScalingId
175+ . eq ( self . auto_proc_scaling_id ) ,
129176 )
177+ . one ( database)
178+ . await ?
179+ . map ( AutoProcScalingStatics :: from) )
130180 }
131181}
132182
@@ -137,19 +187,4 @@ impl Query {
137187 async fn router_data_collection ( & self , id : u32 ) -> DataCollection {
138188 DataCollection { id }
139189 }
140-
141- async fn auto_proc_integration (
142- & self ,
143- ctx : & Context < ' _ > ,
144- data_collection_id : u32 ,
145- ) -> async_graphql:: Result < Vec < AutoProcIntegration > , async_graphql:: Error > {
146- let database = ctx. data :: < DatabaseConnection > ( ) ?;
147- Ok ( auto_proc_integration:: Entity :: find ( )
148- . filter ( auto_proc_integration:: Column :: DataCollectionId . eq ( data_collection_id) )
149- . all ( database)
150- . await ?
151- . into_iter ( )
152- . map ( AutoProcIntegration :: from)
153- . collect ( ) )
154- }
155190}
0 commit comments