diff --git a/apps/indexer/src/storage/mongo/event_store.rs b/apps/indexer/src/storage/mongo/event_store.rs index c4b98d2e..d702b553 100644 --- a/apps/indexer/src/storage/mongo/event_store.rs +++ b/apps/indexer/src/storage/mongo/event_store.rs @@ -27,37 +27,15 @@ impl EventStore for MongoStore { &self, eth_contract_address: &str, ) -> Result { - let pipeline = vec![ - doc! { - "$match": { - "collection_src": eth_contract_address, - } - }, - doc! { - "$project": { - "number_of_tokens": { "$size": "$token_ids" } - } - }, - doc! { - "$group": { - "_id": null, - "total_token_ids": { "$sum": "$number_of_tokens" } - } - }, - ]; + let filter = doc! { + "collection_src": eth_contract_address, + }; - let mut cursor = self + let total_count = self .starknet_bridge_requests - .aggregate(pipeline, None) + .count_documents(filter, None) .await?; - let mut total_count: u64 = 0; - if let Some(doc) = cursor.try_next().await? { - if let Ok(count) = doc.get_i64("total_token_ids") { - total_count = count as u64; - } - } - Ok(total_count) }