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

   <!-- Answer -->
   To find GitHub commits for a specific file in the DevLake database, you 
should query the `commits_diffs` table.
   
   ```md
   #### commits_diffs
   
   This table shows the commits added in a new commit compared to an old 
commit. This table can be used to support tag-based and deploy-based metrics.
   
   The records of this table are computed by 
[RefDiff](https://github.com/apache/incubator-devlake/tree/main/backend/plugins/refdiff)
 plugin. The computation should be manually triggered after using 
[GitRepoExtractor](https://github.com/apache/incubator-devlake/tree/main/backend/plugins/gitextractor)
 to collect commits and refs. The algorithm behind is similar to 
[this](https://github.com/apache/incubator-devlake/compare/v0.8.0%E2%80%A6v0.9.0).
   
   | **field**        | **type** | **length** | **description**                 
                                           | **key** |
   | :--------------- | :------- | :--------- | 
:------------------------------------------------------------------------- | 
:------ |
   | `new_commit_sha` | char     | 40         | The commit new ref/deployment 
points to at the time of collection          | PK      |
   | `old_commit_sha` | char     | 40         | The commit old ref/deployment 
points to at the time of collection          | PK      |
   | `commit_sha`     | char     | 40         | One of the added commits in the 
new ref compared to the old ref/deployment | PK      |
   | `sorting_index`  | varchar  | 255        | An index for debugging, please 
skip it                                     |         |
   ```
   
   Additionally, you may also need to query the `_tool_github_commits` table to 
get detailed information about the commits.
   
   ```go
   type GithubCommit struct {
        Sha            string `gorm:"primaryKey;type:varchar(40)"`
        AuthorId       int
        AuthorName     string `gorm:"type:varchar(255)"`
        AuthorEmail    string `gorm:"type:varchar(255)"`
        AuthoredDate   time.Time
        CommitterId    int
        CommitterName  string `gorm:"type:varchar(255)"`
        CommitterEmail string `gorm:"type:varchar(255)"`
        CommittedDate  time.Time
        Message        string
        Url            string `gorm:"type:varchar(255)"`
        Additions      int    `gorm:"comment:Added lines of code"`
        Deletions      int    `gorm:"comment:Deleted lines of code"`
        archived.NoPKModel
   }
   
   func (GithubCommit) TableName() string {
        return "_tool_github_commits"
   }
   ```
   
   By combining data from both `commits_diffs` and `_tool_github_commits`, you 
can identify and analyze commits related to specific files 
<sup>[[1]](https://github.com/apache/incubator-devlake-website/blob/main/versioned_docs/version-v0.15/DataModels/DevLakeDomainLayerSchema.md)</sup><sup>[[2]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/github/models/migrationscripts/archived/commit.go)</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: dev-unsubscr...@devlake.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to