dosubot[bot] commented on issue #7877:
URL: 
https://github.com/apache/incubator-devlake/issues/7877#issuecomment-2284944731

   <!-- Answer -->
   To resolve the issue of the `commit_files` table being empty and get the 
necessary file information for creating a custom metric for files updated 
during commits, you can use the `customize` plugin provided by Apache DevLake. 
This plugin allows you to create or delete columns in the domain layer schema 
with the data extracted from raw layer tables.
   
   Here is a step-by-step approach:
   
   1. **Use the `customize` plugin** to ensure that the `commit_files` table is 
populated with the necessary data from the raw layer tables.
   
   2. **Check the ETL logic** to ensure that the data from the source code 
management tools (e.g., GitHub, GitLab) is being correctly transformed and 
loaded into the `commit_files` table.
   
   3. **Verify the data extraction configuration** to ensure that the file 
changes are being captured during the data collection process.
   
   Additionally, you can leverage the `gitextractor` plugin, which is designed 
to collect metrics from Git repositories. The `ComponentAndFileLevelMetrics` 
dashboard in Grafana, which shows metrics collected by the `gitextractor` 
plugin, can be a useful reference. Here is an example of a SQL query used in 
the dashboard to gather file-level metrics:
   
   ```sql
   SELECT file_path,
          count(distinct sha) AS modified_num
   FROM commits
   JOIN commit_files
   JOIN repo_commits rc
       ON commit_files.commit_sha = rc.commit_sha
           AND sha=commit_files.commit_sha
           AND $__timeFilter(commits.authored_date)
   WHERE repo_id IN (${repo_id}) and file_path REGEXP  
'(${selected_path:regex})'
   AND $__timeFilter(commits.authored_date)
   GROUP BY  file_path
   ORDER BY  modified_num desc
   LIMIT 15;
   ```
   
   By following these steps and using the `customize` and `gitextractor` 
plugins, you can ensure that the `commit_files` table is populated with the 
necessary data to create custom metrics for files updated during commits 
<sup>[[1]](https://github.com/apache/incubator-devlake-website/blob/main/docs/DataModels/DevLakeDomainLayerSchema.md)</sup><sup>[[2]](https://github.com/apache/incubator-devlake/blob/main/grafana/dashboards/ComponentAndFileLevelMetrics.json)</sup>.
   
   
   <!-- Dosu Comment Footer -->
   *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
   


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