@@ -60,12 +60,11 @@ async fn handle_poll_result(
6060 poll : Vec < ( String , String ) > ,
6161 platform_api_config : & PlatformApiConfig ,
6262) -> Result < Option < Vec < OperationData > > , CollectionError > {
63- let mut keep_ids = poll. iter ( ) . map ( |( id, _) | id) ;
64- for id in previous_updated_at. clone ( ) . keys ( ) {
65- if keep_ids. all ( |keep_id| keep_id != id) {
66- previous_updated_at. remove ( id) ;
67- }
68- }
63+ let removed_ids = previous_updated_at. clone ( ) ;
64+ let removed_ids = removed_ids
65+ . keys ( )
66+ . filter ( |id| poll. iter ( ) . all ( |( keep_id, _) | keep_id != * id) )
67+ . collect :: < Vec < _ > > ( ) ;
6968
7069 let changed_ids: Vec < String > = poll
7170 . into_iter ( )
@@ -77,11 +76,20 @@ async fn handle_poll_result(
7776 } )
7877 . collect ( ) ;
7978
80- if changed_ids. is_empty ( ) {
79+ if changed_ids. is_empty ( ) && removed_ids . is_empty ( ) {
8180 tracing:: debug!( "no operation changed" ) ;
82- Ok ( None )
83- } else {
84- tracing:: debug!( "changed operation ids: {:?}" , changed_ids) ;
81+ return Ok ( None ) ;
82+ }
83+
84+ if !removed_ids. is_empty ( ) {
85+ tracing:: info!( "removed operation ids: {:?}" , removed_ids) ;
86+ for id in removed_ids {
87+ previous_updated_at. remove ( id) ;
88+ }
89+ }
90+
91+ if !changed_ids. is_empty ( ) {
92+ tracing:: info!( "changed operation ids: {:?}" , changed_ids) ;
8593 let full_response = graphql_request :: < OperationCollectionEntriesQuery > (
8694 & OperationCollectionEntriesQuery :: build_query (
8795 operation_collection_entries_query:: Variables {
@@ -91,16 +99,15 @@ async fn handle_poll_result(
9199 platform_api_config,
92100 )
93101 . await ?;
94-
95102 for operation in full_response. operation_collection_entries {
96103 previous_updated_at. insert (
97104 operation. id . clone ( ) ,
98105 OperationData :: from ( & operation) . clone ( ) ,
99106 ) ;
100107 }
101-
102- Ok ( Some ( previous_updated_at. clone ( ) . into_values ( ) . collect ( ) ) )
103108 }
109+
110+ Ok ( Some ( previous_updated_at. clone ( ) . into_values ( ) . collect ( ) ) )
104111}
105112
106113#[ derive( Clone ) ]
0 commit comments