naveenreddymanukonda opened a new issue, #6651:
URL: https://github.com/apache/incubator-devlake/issues/6651

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   
   The query in the documentation is causing discrepancies in the count of 
lines of code changes (additions and deletions) because it incorporates both 
the pull request (PR) merge and PR sync, including those for declined and still 
open PRs. It's worth considering whether we should include all PRs without 
merge in the calculation. Please review this aspect and share your thoughts on 
whether to include lines of code changes from PRs that haven't been merged.
   
   ### What do you expect to happen
   
   To accurately count the lines of code, it's suggested to only consider the 
lines changed in the merged commit.
   
   ### How to reproduce
   
   `SELECT
       DATE_ADD(date(pr.created_date), INTERVAL 
-$interval(date(pr.created_date))+1 DAY) as time,
       pr.id as pr_id,
       prc.commit_sha,
       sum(c.additions)+sum(c.deletions) as loc
     FROM 
       pull_requests pr
       left join pull_request_commits prc on pr.id = prc.pull_request_id
       left join commits c on prc.commit_sha = c.sha
     WHERE
       $__timeFilter(pr.created_date)
       and pr.base_repo_id in ($repo_id)
     group by 1,2,3`
   
   ### Anything else
   
   Below is the proposed query
   `SELECT
       DATE_ADD(date(pr.created_date), INTERVAL 
-$interval(date(pr.created_date))+1 DAY) as time,
       pr.id as pr_id,
       prc.commit_sha,
       sum(c.additions)+sum(c.deletions) as loc
     FROM 
       pull_requests pr
       left join pull_request_commits prc on pr.id = prc.pull_request_id
                and pr.merge_commit_sha = prc.commit_sha
       left join commits c on prc.commit_sha = c.sha
     WHERE
       $__timeFilter(pr.created_date)
       and pr.base_repo_id in ($repo_id)
       and pr.original_status = 'MERGED'
     group by 1,2,3`
   
   ### Version
   
   v0.20.0-beta1
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to