feat(package): gitea: add heatmap contribution model
This commit is contained in:
@@ -405,6 +405,7 @@ func prepareMigrationTasks() []*migration {
|
||||
newMigration(328, "Add TokenPermissions column to ActionRunJob", v1_26.AddTokenPermissionsToActionRunJob),
|
||||
newMigration(329, "Add unique constraint for user badge", v1_26.AddUniqueIndexForUserBadge),
|
||||
newMigration(330, "Add name column to webhook", v1_26.AddNameToWebhook),
|
||||
newMigration(331, "Create heatmap contribution table", v1_26.CreateHeatmapContributionTable),
|
||||
}
|
||||
return preparedMigrations
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_26
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
type HeatmapContribution struct { //revive:disable-line:exported
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
UserID int64 `xorm:"NOT NULL"`
|
||||
RepoID int64 `xorm:"NOT NULL"`
|
||||
CommitSHA string `xorm:"VARCHAR(64) NOT NULL"`
|
||||
AuthorEmail string `xorm:"VARCHAR(320) NOT NULL"`
|
||||
AuthorUnix timeutil.TimeStamp `xorm:"NOT NULL"`
|
||||
CreatedUnix timeutil.TimeStamp `xorm:"created"`
|
||||
UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
|
||||
}
|
||||
|
||||
// TableIndices implements xorm's TableIndices interface.
|
||||
func (c *HeatmapContribution) TableIndices() []*schemas.Index {
|
||||
uniqueContribution := schemas.NewIndex("repo_commit_user", schemas.UniqueType)
|
||||
uniqueContribution.AddColumn("repo_id", "commit_sha", "user_id")
|
||||
|
||||
userAuthorRepo := schemas.NewIndex("u_a_r", schemas.IndexType)
|
||||
userAuthorRepo.AddColumn("user_id", "author_unix", "repo_id")
|
||||
|
||||
return []*schemas.Index{uniqueContribution, userAuthorRepo}
|
||||
}
|
||||
|
||||
func CreateHeatmapContributionTable(x *xorm.Engine) error {
|
||||
_, err := x.SyncWithOptions(xorm.SyncOptions{IgnoreDropIndices: true}, new(HeatmapContribution))
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user