diff --git a/bot/src/bot.rs b/bot/src/bot.rs index 80c4cc1..8b62c4d 100644 --- a/bot/src/bot.rs +++ b/bot/src/bot.rs @@ -76,16 +76,28 @@ pub async fn get_domains_ready_for_renewal( "as": "approval_info", }}, doc! { "$unwind": { "path": "$approval_info", "preserveNullAndEmptyArrays": true } }, + doc! { "$group": { + "_id": "$domain", + "expiry": { "$first": "$expiry" }, + "renewer_address": { "$first": "$renewal_info.renewer_address" }, + "enabled": { "$first": "$renewal_info.enabled" }, + "approval_value": { "$first": { "$ifNull": [ "$approval_info.allowance", "0x0" ] } }, + "allowance": { "$first": "$renewal_info.allowance" }, + "last_renewal": { "$first": "$renewal_info.last_renewal" }, + "meta_hash": { "$first": "$renewal_info.meta_hash" }, + "_cursor": { "$first": "$renewal_info._cursor" }, + }}, doc! { "$project": { - "domain": 1, + "_id": 0, + "domain": "$_id", "expiry": 1, - "renewer_address": "$renewal_info.renewer_address", - "enabled": "$renewal_info.enabled", - "approval_value": { "$ifNull": [ "$approval_info.allowance", "0x0" ] }, - "allowance": "$renewal_info.allowance", - "last_renewal": "$renewal_info.last_renewal", - "meta_hash": "$renewal_info.meta_hash", - "_cursor": "$renewal_info._cursor", + "renewer_address": 1, + "enabled": 1, + "approval_value": 1, + "allowance": 1, + "last_renewal": 1, + "meta_hash": 1, + "_cursor": 1, }}, ];