GitHub user dosubot[bot] added a comment to the discussion: pr_deployed_date 
field in project_pr_metrics  table

<!-- Greeting -->
Hello @boraer! I'm [Dosu](https://dosu.dev), a bot here to help you solve bugs, 
answer questions, and become a contributor. I'm ready to assist you while we 
wait for a human maintainer. How can I help you today?

<!-- Answer -->
The `pr_deployed_date` field in the `project_pr_metrics` table is populated by 
retrieving deployment information for a pull request and calculating the PR 
deploy time. Specifically, the `pr_deployed_date` is set to 
`deployment.FinishedDate` if a deployment is found and its `FinishedDate` is 
not nil. Here's a snippet of the relevant code:

```go
// Get the deployment for the PR
deployment, err := getDeploymentCommit(pr.MergeCommitSha, 
data.Options.ProjectName, db)
if err != nil {
    return nil, err
}

// Calculate PR deploy time
if deployment != nil && deployment.FinishedDate != nil {
    projectPrMetric.PrDeployTime = computeTimeSpan(pr.MergedDate, 
deployment.FinishedDate)
    projectPrMetric.DeploymentCommitId = deployment.Id
    projectPrMetric.PrDeployedDate = deployment.FinishedDate
}
```

This process involves associating pull requests with deployments, which are 
collected from various sources like GitHub, GitLab, Jenkins, etc. The 
calculation of `PR deploy time` is done by subtracting a PR's `merged_date` 
from its `deployed_date` 
<sup>[[1]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/dora/tasks/change_lead_time_calculator.go)</sup><sup>[[2]](https://github.com/apache/incubator-devlake-website/blob/main/versioned_docs/version-v0.21/Metrics/PRDeployTime.md)</sup>.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great 
Response](https://app.dosu.dev/response-feedback/bc82e423-629a-4393-99d8-810b5c5055e4?feedback_type=great_response)
 | [Irrelevant 
Answer](https://app.dosu.dev/response-feedback/bc82e423-629a-4393-99d8-810b5c5055e4?feedback_type=irrelevant_answer)
 | [Incorrect 
Sources](https://app.dosu.dev/response-feedback/bc82e423-629a-4393-99d8-810b5c5055e4?feedback_type=incorrect_sources)
 | [Too 
Verbose](https://app.dosu.dev/response-feedback/bc82e423-629a-4393-99d8-810b5c5055e4?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/bc82e423-629a-4393-99d8-810b5c5055e4?feedback_type=hallucination)
 | [Bug 
Report](https://app.dosu.dev/response-feedback/bc82e423-629a-4393-99d8-810b5c5055e4?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/bc82e423-629a-4393-99d8-810b5c5055e4?feedback_type=other)</sup>


GitHub link: 
https://github.com/apache/incubator-devlake/discussions/8447#discussioncomment-13221385

----
This is an automatically sent email for dev@devlake.apache.org.
To unsubscribe, please send an email to: dev-unsubscr...@devlake.apache.org

Reply via email to