Fix/GitHub deployment time calculation#8715
Merged
klesh merged 8 commits intoapache:mainfrom Feb 26, 2026
Merged
Conversation
Introduce FinishedDate field in GithubDeployment to represent success-priority deployment completion timestamp. This field allows distinguishing SUCCESS timestamp from latest status update time while preserving backward compatibility.
Add logic to derive FinishedDate from deployment statuses. Preference order: 1. Latest SUCCESS timestamp 2. Latest terminal timestamp (FAILURE/ERROR/INACTIVE/ACTIVE) This improves deployment lifecycle accuracy without modifying existing LatestStatus semantics.
Update ConvertDeployment to use tool-layer FinishedDate when populating domain TaskDatesInfo.FinishedDate. Duration is now calculated using resolved finished time instead of UpdatedDate.
Add migration script to auto-migrate GithubDeployment and create nullable finished_date column.
…te and duration Introduce adjustments to existing e2e tests to validate backward compatibility after adding deployment finished date and duration calculation logic. Add `deployment_finished_date` field to `_tool_github_deployments.csv` and `duration_seconds` field to `cicd_deployments.csv`. Ensure historical data remains compatible with the updated behavior.
…tion calculation logic Add test coverage for deployment finished date and duration calculation based on the SUCCESS state instead of relying on the inactive state. Verify fallback behavior when a SUCCESS state is not present.
klesh
reviewed
Feb 23, 2026
Contributor
klesh
left a comment
There was a problem hiding this comment.
Thanks for your contribution.
The overall idea looks solid. Please fix the linting.
| func (*addFinishedDateToGithubDeployment) Up(basicRes context.BasicRes) errors.Error { | ||
| return migrationhelper.AutoMigrateTables( | ||
| basicRes, | ||
| &models.GithubDeployment{}, |
Contributor
There was a problem hiding this comment.
Referencing the active model in a migration script is incorrect because the model will change over time while the script must stay reproducible. Please define a new struct just for this script; feel free to use the other scripts as examples.
Contributor
Author
There was a problem hiding this comment.
Got it, thanks for the explanation. I’ll update the migration
… model Define a dedicated versioned struct for the finished_date migration instead of referencing the evolving GithubDeployment model to ensure deterministic and reproducible schema changes.
…ment extractor Remove redundant restTasks alias and use githubTasks constants consistently to resolve lint warnings and improve import clarity.
klesh
approved these changes
Feb 26, 2026
Contributor
klesh
left a comment
There was a problem hiding this comment.
LGTM. Thanks for your contribution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix deployment finish time calculation in the GitHub GraphQL plugin.
Previously, DevLake used the latest deployment status timestamp (often
inactive) as the deployment completion time. However, GitHub marks a deployment asinactivewhen it is superseded by a newer successful deployment, which may occur significantly later than the actual success event. This led to inflated deployment durations and inaccurate metrics (e.g., PR Deploy Time).This PR introduces a new nullable field
finished_dateinGithubDeploymentand implements success-priority logic:successstatus timestamp if present.finished_dateis used to populateTaskDatesInfo.FinishedDateand calculate deployment duration.This ensures deployment metrics reflect the actual completion time rather than a later superseding status update.
Backward Compatibility
finished_datefield with a backward-compatible migration.LatestStatusState,LatestUpdatedDate) without changing their semantics.Does this close any open issues?
Closes #8654