11use diesel:: { ExpressionMethods , JoinOnDsl , OptionalExtension , QueryDsl , RunQueryDsl } ;
2- use std:: { collections:: HashMap , sync:: Arc , time :: SystemTime } ;
2+ use std:: { collections:: HashMap , sync:: Arc } ;
33
44use graph:: {
55 components:: store:: { BlockStore as _, DeploymentId , DeploymentLocator } ,
@@ -19,8 +19,8 @@ use graph_store_postgres::{
1919} ;
2020use graph_store_postgres:: { ConnectionPool , Shard , Store , SubgraphStore } ;
2121
22- use crate :: manager:: deployment:: DeploymentSearch ;
2322use crate :: manager:: display:: List ;
23+ use crate :: manager:: { deployment:: DeploymentSearch , fmt} ;
2424
2525type UtcDateTime = DateTime < Utc > ;
2626
@@ -260,26 +260,6 @@ pub fn status(pools: HashMap<Shard, ConnectionPool>, dst: &DeploymentSearch) ->
260260 use catalog:: active_copies as ac;
261261 use catalog:: deployment_schemas as ds;
262262
263- fn duration ( start : & UtcDateTime , end : & Option < UtcDateTime > ) -> String {
264- let start = * start;
265- let end = * end;
266-
267- let end = end. unwrap_or ( UtcDateTime :: from ( SystemTime :: now ( ) ) ) ;
268- let duration = end - start;
269-
270- human_duration ( duration)
271- }
272-
273- fn human_duration ( duration : Duration ) -> String {
274- if duration. num_seconds ( ) < 5 {
275- format ! ( "{}ms" , duration. num_milliseconds( ) )
276- } else if duration. num_minutes ( ) < 5 {
277- format ! ( "{}s" , duration. num_seconds( ) )
278- } else {
279- format ! ( "{}m" , duration. num_minutes( ) )
280- }
281- }
282-
283263 let primary = pools
284264 . get ( & * PRIMARY_SHARD )
285265 . ok_or_else ( || anyhow ! ( "can not find deployment with id {}" , dst) ) ?;
@@ -336,7 +316,7 @@ pub fn status(pools: HashMap<Shard, ConnectionPool>, dst: &DeploymentSearch) ->
336316 state. dst. to_string( ) ,
337317 state. target_block_number. to_string( ) ,
338318 on_sync. to_str( ) . to_string( ) ,
339- duration( & state. started_at, & state. finished_at) ,
319+ fmt :: duration( & state. started_at, & state. finished_at) ,
340320 progress,
341321 ] ;
342322 match ( cancelled_at, state. cancelled_at ) {
@@ -378,7 +358,7 @@ pub fn status(pools: HashMap<Shard, ConnectionPool>, dst: &DeploymentSearch) ->
378358 table. next_vid,
379359 table. target_vid,
380360 table. batch_size,
381- human_duration( Duration :: milliseconds( table. duration_ms) ) ,
361+ fmt :: human_duration( Duration :: milliseconds( table. duration_ms) ) ,
382362 ) ;
383363 }
384364
0 commit comments