@@ -1232,7 +1232,7 @@ impl<'a> Connection<'a> {
12321232 . iter ( )
12331233 . map ( |( node, count) | ( node. as_str ( ) , * count) )
12341234 . chain ( missing)
1235- . min_by ( |( _, a ) , ( _ , b ) | a . cmp ( b ) )
1235+ . min_by_key ( |( _, count ) | * count )
12361236 . map ( |( node, _) | NodeId :: new ( node) . map_err ( |( ) | node) )
12371237 . transpose ( )
12381238 // This can't really happen since we filtered by valid NodeId's
@@ -1260,6 +1260,8 @@ impl<'a> Connection<'a> {
12601260 . order_by ( sql :: < i64 > ( "count(*)" ) )
12611261 . load :: < ( String , i64 ) > ( self . conn . as_ref ( ) ) ?;
12621262
1263+ // Any shards that have no deployments in them will not be in
1264+ // 'used'; add them in with a count of 0
12631265 let missing = shards
12641266 . into_iter ( )
12651267 . filter ( |shard| !used. iter ( ) . any ( |( s, _) | s == shard. as_str ( ) ) )
@@ -1268,7 +1270,7 @@ impl<'a> Connection<'a> {
12681270 used. iter ( )
12691271 . map ( |( shard, count) | ( shard. as_str ( ) , * count) )
12701272 . chain ( missing)
1271- . min_by ( |( _, a ) , ( _ , b ) | a . cmp ( b ) )
1273+ . min_by_key ( |( _, count ) | * count )
12721274 . map ( |( shard, _) | Shard :: new ( shard. to_string ( ) ) )
12731275 . transpose ( )
12741276 // This can't really happen since we filtered by valid shards
0 commit comments