Skip to content

Commit 1255e41

Browse files
authored
Operation Collections - fix update checking (#146)
* fix update checking * add changeset * early return
1 parent 7c191fc commit 1255e41

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Fix tool update on every poll - @Jephuff PR #146
2+
3+
Only update the tool list if an operation was removed, changed, or added.

crates/apollo-mcp-registry/src/platform_api/operation_collections/collection_poller.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)