Documentation
¶
Overview ¶
Package models defines domain models for the reviewer roulette system.
Index ¶
Constants ¶
const ( MRStatusPending = "pending" MRStatusInReview = "in_review" MRStatusApproved = "approved" MRStatusMerged = "merged" MRStatusClosed = "closed" )
MRStatus constants.
const ( ReviewerRoleCodeowner = "codeowner" ReviewerRoleTeamMember = "team_member" ReviewerRoleExternal = "external" )
ReviewerRole constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Badge ¶
type Badge struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"uniqueIndex;not null;size:100" json:"name"`
Description string `gorm:"type:text" json:"description"`
Icon string `gorm:"size:50" json:"icon"`
Criteria json.RawMessage `gorm:"type:jsonb" json:"criteria"` // JSON structure for criteria
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Badge represents a badge that can be earned by users.
type BadgeCriteria ¶
type BadgeCriteria struct {
Metric string `json:"metric"`
Operator string `json:"operator"` // "<", ">", ">=", "<=", "==", "top"
Value interface{} `json:"value"`
Period string `json:"period,omitempty"` // "day", "week", "month", "year"
}
BadgeCriteria represents the criteria for earning a badge.
type Configuration ¶
type Configuration struct {
ID uint `gorm:"primaryKey" json:"id"`
Key string `gorm:"uniqueIndex;not null;size:255" json:"key"`
Value json.RawMessage `gorm:"type:jsonb;not null" json:"value"`
UpdatedAt time.Time `json:"updated_at"`
}
Configuration represents a configuration key-value pair.
func (Configuration) TableName ¶
func (Configuration) TableName() string
TableName specifies the table name for Configuration model.
type MRReview ¶
type MRReview struct {
ID uint `gorm:"primaryKey" json:"id"`
GitLabMRIID int `gorm:"column:gitlab_mr_iid;not null" json:"gitlab_mr_iid"`
GitLabProjectID int `gorm:"column:gitlab_project_id;not null" json:"gitlab_project_id"`
MRURL string `gorm:"type:text;not null" json:"mr_url"`
MRTitle string `gorm:"type:text" json:"mr_title"`
MRAuthorID *uint `gorm:"index" json:"mr_author_id"`
MRAuthor *User `gorm:"foreignKey:MRAuthorID" json:"mr_author,omitempty"`
Team string `gorm:"size:100" json:"team"`
RouletteTriggeredAt *time.Time `json:"roulette_triggered_at"`
RouletteTriggeredBy *uint `json:"roulette_triggered_by"`
TriggeredBy *User `gorm:"foreignKey:RouletteTriggeredBy" json:"triggered_by,omitempty"`
BotCommentID *int `gorm:"index" json:"bot_comment_id"` // GitLab note ID for updating the bot's comment
FirstReviewAt *time.Time `json:"first_review_at"`
ApprovedAt *time.Time `json:"approved_at"`
MergedAt *time.Time `json:"merged_at"`
ClosedAt *time.Time `json:"closed_at"`
Status string `gorm:"size:50;index" json:"status"` // 'pending', 'in_review', 'approved', 'merged', 'closed'
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Relationships
Assignments []ReviewerAssignment `gorm:"foreignKey:MRReviewID" json:"assignments,omitempty"`
}
MRReview represents a merge request review tracking.
type OOOStatus ¶
type OOOStatus struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"not null;index" json:"user_id"`
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
StartDate time.Time `gorm:"not null" json:"start_date"`
EndDate time.Time `gorm:"not null" json:"end_date"`
Reason string `gorm:"type:text" json:"reason"`
CreatedAt time.Time `json:"created_at"`
}
OOOStatus represents out-of-office status for a user.
type ReviewMetrics ¶
type ReviewMetrics struct {
ID uint `gorm:"primaryKey" json:"id"`
Date time.Time `gorm:"type:date;not null" json:"date"`
Team string `gorm:"size:100" json:"team"`
UserID *uint `gorm:"index" json:"user_id"`
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
ProjectID *int `json:"project_id"`
TotalReviews int `gorm:"default:0" json:"total_reviews"`
CompletedReviews int `gorm:"default:0" json:"completed_reviews"`
AvgTTFR *int `json:"avg_ttfr"` // Average Time To First Review in minutes
AvgTimeToApproval *int `json:"avg_time_to_approval"` // in minutes
AvgCommentCount *float64 `gorm:"type:decimal(10,2)" json:"avg_comment_count"`
AvgCommentLength *float64 `gorm:"type:decimal(10,2)" json:"avg_comment_length"`
EngagementScore *float64 `gorm:"type:decimal(10,2)" json:"engagement_score"`
CreatedAt time.Time `json:"created_at"`
}
ReviewMetrics represents aggregated review metrics.
func (ReviewMetrics) TableName ¶
func (ReviewMetrics) TableName() string
TableName specifies the table name for ReviewMetrics model.
type ReviewerAssignment ¶
type ReviewerAssignment struct {
ID uint `gorm:"primaryKey" json:"id"`
MRReviewID uint `gorm:"not null;index" json:"mr_review_id"`
MRReview MRReview `gorm:"foreignKey:MRReviewID" json:"mr_review,omitempty"`
UserID uint `gorm:"not null;index" json:"user_id"`
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
Role string `gorm:"size:50" json:"role"` // 'codeowner', 'team_member', 'external'
AssignedAt time.Time `json:"assigned_at"`
StartedReviewAt *time.Time `json:"started_review_at"` // when they add themselves as reviewer
FirstCommentAt *time.Time `json:"first_comment_at"`
ApprovedAt *time.Time `json:"approved_at"`
CommentCount int `gorm:"default:0" json:"comment_count"`
CommentLength int `gorm:"column:comment_total_length;default:0" json:"comment_total_length"`
}
ReviewerAssignment represents a reviewer assigned to an MR.
func (ReviewerAssignment) TableName ¶
func (ReviewerAssignment) TableName() string
TableName specifies the table name for ReviewerAssignment model.
type User ¶
type User struct {
ID uint `gorm:"primaryKey" json:"id"`
GitLabID int `gorm:"column:gitlab_id;uniqueIndex;not null" json:"gitlab_id"`
Username string `gorm:"uniqueIndex;not null;size:255" json:"username"`
Email string `gorm:"size:255" json:"email"`
Role string `gorm:"size:50" json:"role"` // 'dev' or 'ops'
Team string `gorm:"size:100" json:"team"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
User represents a GitLab user in the system.
type UserBadge ¶
type UserBadge struct {
ID uint `gorm:"primaryKey" json:"id"`
UserID uint `gorm:"not null;index" json:"user_id"`
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
BadgeID uint `gorm:"not null;index" json:"badge_id"`
Badge Badge `gorm:"foreignKey:BadgeID" json:"badge,omitempty"`
EarnedAt time.Time `gorm:"not null" json:"earned_at"`
}
UserBadge represents a badge earned by a user.