@@ -5,12 +5,20 @@ use async_graphql::{
55 ComplexObject , Context , EmptyMutation , EmptySubscription , Object , Schema , SchemaBuilder ,
66} ;
77use aws_sdk_s3:: presigning:: PresigningConfig ;
8- use entities:: { DataCollection , DataProcessing , ProcessingJob , ProcessingJobParameter , AutoProcIntegration } ;
9- use models:: { data_collection_file_attachment, processing_job, processing_job_parameter, auto_proc_integration} ;
8+ use entities:: {
9+ AutoProcIntegration , DataCollection , DataProcessing , ProcessingJob , ProcessingJobParameter ,
10+ AutoProc , AutoProcScaling ,
11+ } ;
12+ use models:: {
13+ auto_proc_integration, auto_proc_program, data_collection_file_attachment, processing_job,
14+ processing_job_parameter, auto_proc, auto_proc_scaling,
15+ } ;
1016use sea_orm:: { ColumnTrait , DatabaseConnection , EntityTrait , QueryFilter } ;
1117use std:: time:: Duration ;
1218use url:: Url ;
1319
20+ use self :: entities:: AutoProcProgram ;
21+
1422/// The GraphQL schema exposed by the service
1523pub type RootSchema = Schema < Query , EmptyMutation , EmptySubscription > ;
1624
@@ -92,11 +100,56 @@ impl ProcessingJob {
92100 }
93101}
94102
103+ #[ ComplexObject ]
104+ impl AutoProcIntegration {
105+ async fn auto_proc_program (
106+ & self ,
107+ ctx : & Context < ' _ > ,
108+ ) -> async_graphql:: Result < Vec < AutoProcProgram > > {
109+ let database = ctx. data :: < DatabaseConnection > ( ) ?;
110+ Ok ( auto_proc_program:: Entity :: find ( )
111+ . filter ( auto_proc_program:: Column :: AutoProcProgramId . eq ( self . auto_proc_program_id ) )
112+ . all ( database)
113+ . await ?
114+ . into_iter ( )
115+ . map ( AutoProcProgram :: from)
116+ . collect ( ) )
117+ }
118+ }
119+
120+ #[ ComplexObject ]
121+ impl AutoProcProgram {
122+ async fn auto_proc ( & self , ctx : & Context < ' _ > , ) -> async_graphql:: Result < Option < AutoProc > > {
123+ let database = ctx. data :: < DatabaseConnection > ( ) ?;
124+ Ok ( auto_proc:: Entity :: find ( )
125+ . filter ( auto_proc:: Column :: AutoProcProgramId . eq ( self . auto_proc_program_id ) )
126+ . one ( database)
127+ . await ?
128+ . map ( AutoProc :: from)
129+ )
130+ }
131+ }
132+
95133#[ Object ]
96134impl Query {
97135 /// Reference datasets resolver for the router
98136 #[ graphql( entity) ]
99137 async fn router_data_collection ( & self , id : u32 ) -> DataCollection {
100138 DataCollection { id }
101139 }
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+ }
102155}
0 commit comments