Get estimated completion time programmatically

Is there a way to get the estimated completion time for a deploy programmatically? I’m creating a dashboard for our QA team that lists all of our environments and if they are currently up or down. If they are down due to a deployment I would like to display the estimated completion time.

Thanks in advance for your help

Hi @jweems!

Yes, what it looks like our page does it is grabs the most recent 4 deployments using this endpoint:

/api/[Space-Id]/deployments?skip=0&take=4&projects=[Project-Id]&environments=[Environment-Id]

Example: https://local.octopusdemos.app/api/Spaces-1/deployments?skip=0&take=4&projects=Projects-561&environments=Environments-1

It will then pull the task ID from each deployment:

Then it will hit the endpoint: /api/tasks/[Task-Id]?spaces=[Space-Id]&includeSystem=true

Example: https://local.octopusdemos.app/api/tasks/ServerTasks-78645?spaces=Spaces-1&includeSystem=true

That will give you the start time and completed time:
image

That is not the most efficient way to get that information though (I wanted to show how the page does that).

What you can do instead is hit the tasks endpoint with filters: /api/tasks?skip=0&take=10&environment=[Environment-Id]&project=[Project-Id]&states=Success&spaces=[Space-Id]&includeSystem=false

For Example: https://local.octopusdemos.app/api/tasks?skip=0&environment=Environments-1&project=Projects-582&states=Success&spaces=Spaces-1&includeSystem=false

That will give you a list of tasks you can loop through. For each task calculate the duration based on the start time and completed time and then calculate an average.

I hope that helps!

I really appreciate you showing that, I’ve always wondered how that number was calculated. Unfortunately that’s more involved than I have time to implement right now so I’m going to have to back burner this feature. If one doesn’t exist already I will add a user voice request to get have the server calculate and expose this.

I agree, it’d be nice to have that logic behind a server instead of having the UI calc it for you.

If anyone else thinks this is a good idea here the link to the User Voice post.