xgdyp commented on PR #3216:
URL: 
https://github.com/apache/incubator-devlake/pull/3216#issuecomment-1260958764

   Using this repo_snapshot table, we can make a query like 
   ```
   SELECT weekday(commits.committed_date) AS wd,
           count(*)
   FROM repo_snapshot
   JOIN commits
       ON commits.sha=repo_snapshot.commit_sha
   WHERE repo_id LIKE 'github:GithubRepo:1:491450511'
   GROUP BY  wd
   ORDER BY  wd ;
   ```
   to get in which day,  the code has highest chance to stay in repository.
   In lake, the result is  Wednesday.
   
![image](https://user-images.githubusercontent.com/37795442/192797225-f3b599f8-ec98-42d6-bfcb-cd103edbb27b.png)
   we can also use a query like
   ```
   SELECT file_path,
           avg(timestampdiff(day,
           commits.committed_date,
           now())) AS line_age
   FROM repo_snapshot
   JOIN commits
       ON repo_snapshot.commit_sha = commits.sha
   WHERE repo_id LIKE 'github:GithubRepo:1:491450511'
   GROUP BY  file_path
   ORDER BY  line_age desc;
   ```
   to get the answer of which file has the longest average line age
   and the top 10 results are :
   
![image](https://user-images.githubusercontent.com/37795442/192798471-af5d58c9-1fd7-4104-a72c-80f2c7fcd1e3.png)
   
   


-- 
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