services

package
v0.0.0-...-51d4900 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IndexUsers         = "users"
	IndexRepositories  = "repositories"
	IndexCommits       = "commits"
	IndexOrganizations = "organizations"
	IndexCode          = "code"
)

Index names

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessEvent

type AccessEvent struct {
	Timestamp time.Time `json:"timestamp"`
	User      string    `json:"user"`
	Action    string    `json:"action"`
	Resource  string    `json:"resource"`
	Result    string    `json:"result"`
	IPAddress string    `json:"ip_address"`
	UserAgent string    `json:"user_agent"`
	RiskLevel string    `json:"risk_level"`
}

type ActionSummary

type ActionSummary struct {
	Action string `json:"action"`
	Count  int    `json:"count"`
	Users  int    `json:"unique_users"`
}

type ActivityFilters

type ActivityFilters struct {
	Actions     []models.ActivityAction `json:"actions,omitempty"`
	ActorIDs    []uuid.UUID             `json:"actor_ids,omitempty"`
	TargetTypes []string                `json:"target_types,omitempty"`
	TargetIDs   []uuid.UUID             `json:"target_ids,omitempty"`
	StartDate   *time.Time              `json:"start_date,omitempty"`
	EndDate     *time.Time              `json:"end_date,omitempty"`
	Limit       int                     `json:"limit,omitempty"`
	Offset      int                     `json:"offset,omitempty"`
	SortBy      string                  `json:"sort_by,omitempty"`    // "created_at", "action", "actor"
	SortOrder   string                  `json:"sort_order,omitempty"` // "asc", "desc"
}

Request/Response Types

type ActivityResponse

type ActivityResponse struct {
	Activities    []*EnhancedOrganizationActivity `json:"activities"`
	TotalCount    int                             `json:"total_count"`
	FilteredCount int                             `json:"filtered_count"`
	HasMore       bool                            `json:"has_more"`
	NextOffset    int                             `json:"next_offset"`
}

type ActivityService

type ActivityService interface {
	LogActivity(ctx context.Context, orgID, actorID uuid.UUID, action models.ActivityAction, targetType string, targetID *uuid.UUID, metadata map[string]interface{}) error
	GetActivity(ctx context.Context, orgName string, limit, offset int) ([]*models.OrganizationActivity, error)
}

func NewActivityService

func NewActivityService(db *gorm.DB) ActivityService

type ActivityStatistics

type ActivityStatistics struct {
	TotalViews    int64             `json:"total_views"`
	TotalClones   int64             `json:"total_clones"`
	TotalForks    int64             `json:"total_forks"`
	TotalStars    int64             `json:"total_stars"`
	TotalWatchers int64             `json:"total_watchers"`
	ActivityTrend []TimeSeriesPoint `json:"activity_trend"`
}

type ActivitySubscriptionFilters

type ActivitySubscriptionFilters struct {
	Actions     []models.ActivityAction `json:"actions,omitempty"`
	TargetTypes []string                `json:"target_types,omitempty"`
	RiskLevels  []string                `json:"risk_levels,omitempty"`
	RealTime    bool                    `json:"real_time"`
	Email       bool                    `json:"email"`
	Webhook     string                  `json:"webhook,omitempty"`
}

type ActivitySummary

type ActivitySummary struct {
	Date        time.Time `json:"date"`
	Action      string    `json:"action"`
	ActorName   string    `json:"actor_name"`
	TargetType  string    `json:"target_type"`
	TargetName  string    `json:"target_name"`
	Description string    `json:"description"`
}

type ActivityTrendData

type ActivityTrendData struct {
	Date         time.Time `json:"date"`
	Commits      int       `json:"commits"`
	Issues       int       `json:"issues"`
	PullRequests int       `json:"pull_requests"`
	Comments     int       `json:"comments"`
}

type ActivityTrendPoint

type ActivityTrendPoint struct {
	Date  time.Time `json:"date"`
	Count int       `json:"count"`
}

type AdminEvent

type AdminEvent struct {
	Timestamp time.Time `json:"timestamp"`
	Admin     string    `json:"admin"`
	Action    string    `json:"action"`
	Target    string    `json:"target"`
	Changes   string    `json:"changes"`
	Approved  bool      `json:"approved"`
}

type AnalyticsService

type AnalyticsService interface {
	// Event tracking
	RecordEvent(ctx context.Context, event *models.AnalyticsEvent) error
	GetEvents(ctx context.Context, filters EventFilters) ([]*models.AnalyticsEvent, int64, error)

	// Metrics recording and querying
	RecordMetric(ctx context.Context, metric *models.AnalyticsMetric) error
	GetMetrics(ctx context.Context, filters MetricFilters) ([]*models.AnalyticsMetric, error)

	// Repository analytics
	GetRepositoryAnalytics(ctx context.Context, repoID uuid.UUID, period Period) (*models.RepositoryAnalytics, error)
	UpdateRepositoryAnalytics(ctx context.Context, repoID uuid.UUID, date time.Time) error
	GetRepositoryInsights(ctx context.Context, repoID uuid.UUID, filters InsightFilters) (*RepositoryInsights, error)
	GetRepositoryCodeStats(ctx context.Context, repoID uuid.UUID) (*CodeStatistics, error)
	GetRepositoryContributorStats(ctx context.Context, repoID uuid.UUID, filters InsightFilters) (*ContributorStatistics, error)
	GetRepositoryActivityStats(ctx context.Context, repoID uuid.UUID, filters InsightFilters) (*ActivityStatistics, error)

	GetRepositoryPRStats(ctx context.Context, repoID uuid.UUID, filters InsightFilters) (*PullRequestStatistics, error)
	GetRepositoryPerformanceStats(ctx context.Context, repoID uuid.UUID, filters InsightFilters) (*PerformanceStatistics, error)

	// User analytics
	GetUserAnalytics(ctx context.Context, userID uuid.UUID, period Period) (*models.UserAnalytics, error)
	UpdateUserAnalytics(ctx context.Context, userID uuid.UUID, date time.Time) error
	GetUserInsights(ctx context.Context, userID uuid.UUID, filters InsightFilters) (*UserInsights, error)

	// Organization analytics
	GetOrganizationAnalytics(ctx context.Context, orgID uuid.UUID, period Period) (*models.OrganizationAnalytics, error)
	UpdateOrganizationAnalytics(ctx context.Context, orgID uuid.UUID, date time.Time) error
	GetOrganizationInsights(ctx context.Context, orgID uuid.UUID, filters InsightFilters) (*OrganizationInsights, error)

	// System analytics
	GetSystemAnalytics(ctx context.Context, period Period) (*models.SystemAnalytics, error)
	UpdateSystemAnalytics(ctx context.Context, date time.Time) error
	GetSystemInsights(ctx context.Context, filters InsightFilters) (*SystemInsights, error)

	// Performance monitoring
	RecordPerformanceLog(ctx context.Context, log *models.PerformanceLog) error
	GetPerformanceLogs(ctx context.Context, filters PerformanceFilters) ([]*models.PerformanceLog, int64, error)
	GetPerformanceMetrics(ctx context.Context, filters PerformanceFilters) (*PerformanceMetrics, error)

	// Data aggregation and reporting
	AggregateMetrics(ctx context.Context, period Period) error
	GenerateReport(ctx context.Context, reportType ReportType, filters ReportFilters) (*Report, error)
	ExportData(ctx context.Context, exportType ExportType, filters ExportFilters) ([]byte, error)
}

AnalyticsService provides analytics and monitoring operations

func NewAnalyticsService

func NewAnalyticsService(db *gorm.DB, logger *logrus.Logger) AnalyticsService

NewAnalyticsService creates a new analytics service

type AuditSummary

type AuditSummary struct {
	Period             string               `json:"period"`
	TotalActivities    int                  `json:"total_activities"`
	UniqueUsers        int                  `json:"unique_users"`
	TopActions         []ActionSummary      `json:"top_actions"`
	ActivityTrends     []ActivityTrendPoint `json:"activity_trends"`
	SecurityInsights   *SecurityInsights    `json:"security_insights"`
	ComplianceStatus   map[string]bool      `json:"compliance_status"`
	RecommendedActions []string             `json:"recommended_actions"`
}

type BandwidthUsageMetrics

type BandwidthUsageMetrics struct {
	TotalUsedGB  float64               `json:"total_used_gb"`
	TotalLimitGB float64               `json:"total_limit_gb"`
	UsagePercent float64               `json:"usage_percent"`
	DailyUsage   []DailyBandwidthUsage `json:"daily_usage"`
}

type BranchRestrictions

type BranchRestrictions struct {
	Users []string `json:"users"`
	Teams []string `json:"teams"`
}

BranchRestrictions represents push restrictions for branch protection

type BranchService

type BranchService interface {
	List(ctx context.Context, repoID uuid.UUID) ([]*models.Branch, error)
	Get(ctx context.Context, repoID uuid.UUID, branchName string) (*models.Branch, error)
	Create(ctx context.Context, repoID uuid.UUID, req CreateBranchRequest) (*models.Branch, error)
	Delete(ctx context.Context, repoID uuid.UUID, branchName string) error
	SetDefault(ctx context.Context, repoID uuid.UUID, branchName string) error

	// Branch protection
	GetProtectionRule(ctx context.Context, repoID uuid.UUID, pattern string) (*models.BranchProtectionRule, error)
	GetProtectionRuleForBranch(ctx context.Context, repoID uuid.UUID, branchName string) (*models.BranchProtectionRule, error)
	CreateProtectionRule(ctx context.Context, repoID uuid.UUID, req CreateBranchProtectionRequest) (*models.BranchProtectionRule, error)
	UpdateProtectionRule(ctx context.Context, ruleID uuid.UUID, req UpdateBranchProtectionRequest) (*models.BranchProtectionRule, error)
	DeleteProtectionRule(ctx context.Context, ruleID uuid.UUID) error
	ListProtectionRules(ctx context.Context, repoID uuid.UUID) ([]*models.BranchProtectionRule, error)

	// Sync operations
	SyncBranchesFromGit(ctx context.Context, repoID uuid.UUID) error
}

BranchService provides branch management operations

func NewBranchService

func NewBranchService(db *gorm.DB, gitService git.GitService, repositoryService RepositoryService, logger *logrus.Logger) BranchService

NewBranchService creates a new branch service

type CodeStatistics

type CodeStatistics struct {
	TotalLinesOfCode  int64             `json:"total_lines_of_code"`
	TotalFiles        int64             `json:"total_files"`
	TotalCommits      int64             `json:"total_commits"`
	TotalBranches     int64             `json:"total_branches"`
	LanguageBreakdown map[string]int64  `json:"language_breakdown"`
	CommitActivity    []TimeSeriesPoint `json:"commit_activity"`
}

type ComplianceReport

type ComplianceReport struct {
	ReportType       string                  `json:"report_type"`
	Period           string                  `json:"period"`
	GeneratedAt      time.Time               `json:"generated_at"`
	Organization     string                  `json:"organization"`
	Summary          *ComplianceSummary      `json:"summary"`
	AccessEvents     []*AccessEvent          `json:"access_events"`
	SecurityEvents   []*SecurityEvent        `json:"security_events"`
	DataEvents       []*DataEvent            `json:"data_events"`
	AdminEvents      []*AdminEvent           `json:"admin_events"`
	PolicyViolations []*PolicyViolationEvent `json:"policy_violations"`
}

type ComplianceSummary

type ComplianceSummary struct {
	TotalEvents      int     `json:"total_events"`
	SecurityEvents   int     `json:"security_events"`
	AccessEvents     int     `json:"access_events"`
	DataEvents       int     `json:"data_events"`
	AdminEvents      int     `json:"admin_events"`
	HighRiskEvents   int     `json:"high_risk_events"`
	PolicyViolations int     `json:"policy_violations"`
	ComplianceScore  float64 `json:"compliance_score"`
}

type ContributorStat

type ContributorStat struct {
	UserID       uuid.UUID `json:"user_id"`
	Username     string    `json:"username"`
	CommitCount  int64     `json:"commit_count"`
	LinesAdded   int64     `json:"lines_added"`
	LinesDeleted int64     `json:"lines_deleted"`
}

type ContributorStatistics

type ContributorStatistics struct {
	TotalContributors   int64             `json:"total_contributors"`
	ActiveContributors  int64             `json:"active_contributors"`
	TopContributors     []ContributorStat `json:"top_contributors"`
	ContributorActivity []TimeSeriesPoint `json:"contributor_activity"`
}

type CostBreakdownData

type CostBreakdownData struct {
	Category   string  `json:"category"`
	Amount     float64 `json:"amount"`
	Percentage float64 `json:"percentage"`
}

type CreateBranchProtectionRequest

type CreateBranchProtectionRequest struct {
	Pattern                    string                      `json:"pattern"`
	RequiredStatusChecks       *RequiredStatusChecks       `json:"required_status_checks,omitempty"`
	EnforceAdmins              bool                        `json:"enforce_admins"`
	RequiredPullRequestReviews *RequiredPullRequestReviews `json:"required_pull_request_reviews,omitempty"`
	Restrictions               *BranchRestrictions         `json:"restrictions,omitempty"`
}

CreateBranchProtectionRequest represents a request to create a branch protection rule

type CreateBranchRequest

type CreateBranchRequest struct {
	Name    string `json:"name"`
	FromRef string `json:"from_ref,omitempty"` // Branch or commit to create from
}

CreateBranchRequest represents a request to create a branch

type CreateCustomRoleRequest

type CreateCustomRoleRequest struct {
	Name        string                 `json:"name" binding:"required,min=1,max=255"`
	Description string                 `json:"description,omitempty"`
	Permissions map[string]interface{} `json:"permissions" binding:"required"`
	Color       string                 `json:"color,omitempty"`
}

Request/Response Types

type CreateGitHookRequest

type CreateGitHookRequest struct {
	HookType  string `json:"hook_type"`  // pre-receive, post-receive, update, etc.
	Script    string `json:"script"`     // Hook script content
	Language  string `json:"language"`   // bash, python, etc.
	IsEnabled bool   `json:"is_enabled"` // Whether the hook is enabled
	Order     int    `json:"order"`      // Execution order for multiple hooks
}

CreateGitHookRequest represents a request to create a Git hook

type CreateOrgTemplateRequest

type CreateOrgTemplateRequest struct {
	TemplateType  models.TemplateType    `json:"template_type" binding:"required"`
	Name          string                 `json:"name" binding:"required,min=1,max=255"`
	Description   string                 `json:"description,omitempty"`
	Configuration map[string]interface{} `json:"configuration" binding:"required"`
}

type CreateOrganizationRequest

type CreateOrganizationRequest struct {
	Login        string `json:"login" binding:"required,min=1,max=255"`
	Name         string `json:"name" binding:"required,min=1,max=255"`
	Description  string `json:"description,omitempty"`
	AvatarURL    string `json:"avatar_url,omitempty"`
	Website      string `json:"website,omitempty"`
	Location     string `json:"location,omitempty"`
	Email        string `json:"email,omitempty"`
	BillingEmail string `json:"billing_email,omitempty"`
}

Request/Response Types

type CreatePolicyRequest

type CreatePolicyRequest struct {
	PolicyType    models.PolicyType      `json:"policy_type" binding:"required"`
	Name          string                 `json:"name" binding:"required,min=1,max=255"`
	Description   string                 `json:"description,omitempty"`
	Configuration map[string]interface{} `json:"configuration" binding:"required"`
	Enabled       bool                   `json:"enabled"`
	Enforcement   string                 `json:"enforcement,omitempty"`
}

type CreatePullRequestRequest

type CreatePullRequestRequest struct {
	Title               string     `json:"title" binding:"required"`
	Body                string     `json:"body"`
	Head                string     `json:"head" binding:"required"`
	Base                string     `json:"base" binding:"required"`
	HeadRepositoryID    *uuid.UUID `json:"head_repository_id"`
	Draft               bool       `json:"draft"`
	MaintainerCanModify bool       `json:"maintainer_can_modify"`
}

type CreateRepositoryRequest

type CreateRepositoryRequest struct {
	OwnerID       uuid.UUID         `json:"owner_id"`
	OwnerType     models.OwnerType  `json:"owner_type"`
	Name          string            `json:"name"`
	Description   string            `json:"description,omitempty"`
	DefaultBranch string            `json:"default_branch,omitempty"`
	Visibility    models.Visibility `json:"visibility"`
	IsTemplate    bool              `json:"is_template,omitempty"`
	HasIssues     bool              `json:"has_issues"`

	HasWiki             bool `json:"has_wiki"`
	HasDownloads        bool `json:"has_downloads"`
	AllowMergeCommit    bool `json:"allow_merge_commit"`
	AllowSquashMerge    bool `json:"allow_squash_merge"`
	AllowRebaseMerge    bool `json:"allow_rebase_merge"`
	DeleteBranchOnMerge bool `json:"delete_branch_on_merge"`
	AutoInit            bool `json:"auto_init"` // Initialize with README
}

CreateRepositoryRequest represents a request to create a repository

type CreateTeamFromTemplateRequest

type CreateTeamFromTemplateRequest struct {
	Name           string                 `json:"name" binding:"required,min=1,max=255"`
	Description    string                 `json:"description,omitempty"`
	Privacy        models.TeamPrivacy     `json:"privacy" binding:"required"`
	ParentTeamID   *uuid.UUID             `json:"parent_team_id,omitempty"`
	TemplateConfig map[string]interface{} `json:"template_config,omitempty"`
}

type CreateTeamRequest

type CreateTeamRequest struct {
	Name         string             `json:"name" binding:"required,min=1,max=255"`
	Description  string             `json:"description,omitempty"`
	Privacy      models.TeamPrivacy `json:"privacy" binding:"required"`
	ParentTeamID *uuid.UUID         `json:"parent_team_id,omitempty"`
}

Request/Response Types for Teams

type CreateTemplateRequest

type CreateTemplateRequest struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Category    string   `json:"category"`
	Tags        []string `json:"tags"`
	IsFeatured  bool     `json:"is_featured"`
	IsPublic    bool     `json:"is_public"`
}

CreateTemplateRequest represents a request to create a repository template

type CustomRoleService

type CustomRoleService interface {
	CreateCustomRole(ctx context.Context, orgName string, req CreateCustomRoleRequest) (*models.CustomRole, error)
	GetCustomRole(ctx context.Context, orgName string, roleID uuid.UUID) (*models.CustomRole, error)
	UpdateCustomRole(ctx context.Context, orgName string, roleID uuid.UUID, req UpdateCustomRoleRequest) (*models.CustomRole, error)
	DeleteCustomRole(ctx context.Context, orgName string, roleID uuid.UUID) error
	ListCustomRoles(ctx context.Context, orgName string) ([]*models.CustomRole, error)
	SetDefaultRole(ctx context.Context, orgName string, roleID uuid.UUID) error
}

Advanced Organization Service Interfaces

func NewCustomRoleService

func NewCustomRoleService(db *gorm.DB, as ActivityService) CustomRoleService

type DailyBandwidthUsage

type DailyBandwidthUsage struct {
	Date    time.Time `json:"date"`
	UsageGB float64   `json:"usage_gb"`
}

type DashboardMetrics

type DashboardMetrics struct {
	Overview        *OverviewMetrics       `json:"overview"`
	RecentActivity  []*ActivitySummary     `json:"recent_activity"`
	TopRepositories []*RepositorySummary   `json:"top_repositories"`
	ActiveMembers   []*MemberSummary       `json:"active_members"`
	SecurityAlerts  []*SecurityAlert       `json:"security_alerts"`
	StorageUsage    *StorageUsageMetrics   `json:"storage_usage"`
	BandwidthUsage  *BandwidthUsageMetrics `json:"bandwidth_usage"`
}

Analytics Data Structures

type DataEvent

type DataEvent struct {
	Timestamp  time.Time `json:"timestamp"`
	User       string    `json:"user"`
	Action     string    `json:"action"`
	DataType   string    `json:"data_type"`
	Resource   string    `json:"resource"`
	Size       int64     `json:"size"`
	Encryption bool      `json:"encryption"`
}

type DeployKeyService

type DeployKeyService struct {
	// contains filtered or unexported fields
}

DeployKeyService handles deploy key management

func NewDeployKeyService

func NewDeployKeyService(db *gorm.DB, logger *logrus.Logger) *DeployKeyService

NewDeployKeyService creates a new deploy key service

func (*DeployKeyService) CreateDeployKey

func (s *DeployKeyService) CreateDeployKey(ctx context.Context, repositoryID uuid.UUID, title, key string, readOnly bool) (*models.DeployKey, error)

CreateDeployKey creates a new deploy key

func (*DeployKeyService) DeleteDeployKey

func (s *DeployKeyService) DeleteDeployKey(ctx context.Context, deployKeyID uuid.UUID) error

DeleteDeployKey deletes a deploy key

func (*DeployKeyService) ExtractKeyComment

func (s *DeployKeyService) ExtractKeyComment(keyStr string) string

ExtractKeyComment extracts the comment from an SSH key

func (*DeployKeyService) FindDeployKeyByFingerprint

func (s *DeployKeyService) FindDeployKeyByFingerprint(ctx context.Context, fingerprint string) (*models.DeployKey, error)

FindDeployKeyByFingerprint finds a deploy key by its fingerprint

func (*DeployKeyService) GetDeployKey

func (s *DeployKeyService) GetDeployKey(ctx context.Context, deployKeyID uuid.UUID) (*models.DeployKey, error)

GetDeployKey retrieves a deploy key by ID

func (*DeployKeyService) GetKeySize

func (s *DeployKeyService) GetKeySize(keyStr string) (int, error)

GetKeySize returns the size of the SSH key in bits

func (*DeployKeyService) GetKeyType

func (s *DeployKeyService) GetKeyType(keyStr string) (string, error)

GetKeyType returns the type of SSH key (rsa, ed25519, ecdsa, etc.)

func (*DeployKeyService) IsKeySecure

func (s *DeployKeyService) IsKeySecure(keyStr string) (bool, []string, error)

IsKeySecure checks if the SSH key meets security requirements

func (*DeployKeyService) ListDeployKeys

func (s *DeployKeyService) ListDeployKeys(ctx context.Context, repositoryID uuid.UUID) ([]models.DeployKey, error)

ListDeployKeys lists all deploy keys for a repository

func (*DeployKeyService) UpdateLastUsed

func (s *DeployKeyService) UpdateLastUsed(ctx context.Context, fingerprint string) error

UpdateLastUsed updates the last used timestamp for a deploy key

func (*DeployKeyService) ValidateKeyTitle

func (s *DeployKeyService) ValidateKeyTitle(title string) error

ValidateKeyTitle validates the title for a deploy key

func (*DeployKeyService) ValidateSSHKey

func (s *DeployKeyService) ValidateSSHKey(key string) error

ValidateSSHKey validates an SSH key format

func (*DeployKeyService) VerifyDeployKey

func (s *DeployKeyService) VerifyDeployKey(ctx context.Context, deployKeyID uuid.UUID) error

VerifyDeployKey verifies a deploy key format and updates its verification status

type ElasticsearchService

type ElasticsearchService struct {
	// contains filtered or unexported fields
}

ElasticsearchService provides search functionality using Elasticsearch

func NewElasticsearchService

func NewElasticsearchService(config interface{}, logger *logrus.Logger) (*ElasticsearchService, error)

func (*ElasticsearchService) DeleteDocument

func (es *ElasticsearchService) DeleteDocument(index, id string) error

func (*ElasticsearchService) IndexCommit

func (es *ElasticsearchService) IndexCommit(commit *models.Commit) error

func (*ElasticsearchService) IndexOrganization

func (es *ElasticsearchService) IndexOrganization(org *models.Organization) error

func (*ElasticsearchService) IndexRepository

func (es *ElasticsearchService) IndexRepository(repo *models.Repository) error

func (*ElasticsearchService) IndexUser

func (es *ElasticsearchService) IndexUser(user *models.User) error

Stub implementations for required methods

func (*ElasticsearchService) IsEnabled

func (es *ElasticsearchService) IsEnabled() bool

func (*ElasticsearchService) Search

func (es *ElasticsearchService) Search(filter interface{}) (*SearchResults, error)

type EnhancedOrganizationActivity

type EnhancedOrganizationActivity struct {
	*models.OrganizationActivity
	ActorDetails  *UserDetails   `json:"actor_details,omitempty"`
	TargetDetails *TargetDetails `json:"target_details,omitempty"`
	RiskLevel     string         `json:"risk_level"`
	IPAddress     string         `json:"ip_address,omitempty"`
	UserAgent     string         `json:"user_agent,omitempty"`
	Location      string         `json:"location,omitempty"`
}

type EventFilters

type EventFilters struct {
	EventTypes     []models.EventType `json:"event_types,omitempty"`
	ActorID        *uuid.UUID         `json:"actor_id,omitempty"`
	RepositoryID   *uuid.UUID         `json:"repository_id,omitempty"`
	OrganizationID *uuid.UUID         `json:"organization_id,omitempty"`
	StartDate      *time.Time         `json:"start_date,omitempty"`
	EndDate        *time.Time         `json:"end_date,omitempty"`
	Status         string             `json:"status,omitempty"`
	Limit          int                `json:"limit,omitempty"`
	Offset         int                `json:"offset,omitempty"`
}

EventFilters for filtering analytics events

type ExportFilters

type ExportFilters struct {
	Type           ExportType `json:"type"`
	DataType       string     `json:"data_type"` // events, metrics, analytics
	TargetID       *uuid.UUID `json:"target_id,omitempty"`
	StartDate      *time.Time `json:"start_date,omitempty"`
	EndDate        *time.Time `json:"end_date,omitempty"`
	IncludeHeaders bool       `json:"include_headers,omitempty"`
}

type ExportType

type ExportType string

Export types

const (
	ExportTypeCSV  ExportType = "csv"
	ExportTypeJSON ExportType = "json"
	ExportTypeXLSX ExportType = "xlsx"
)

type ExternalSyncStatus

type ExternalSyncStatus struct {
	ID        uuid.UUID      `json:"id" gorm:"type:uuid;primaryKey;default:(gen_random_uuid())"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`

	TeamID         uuid.UUID `json:"team_id" gorm:"type:uuid;not null;index"`
	ExternalSystem string    `json:"external_system" gorm:"not null;size:100"`
	LastSyncAt     time.Time `json:"last_sync_at"`
	NextSyncAt     time.Time `json:"next_sync_at"`
	SyncStatus     string    `json:"sync_status" gorm:"size:50"`
	MembersAdded   int       `json:"members_added" gorm:"default:0"`
	MembersRemoved int       `json:"members_removed" gorm:"default:0"`
	MembersUpdated int       `json:"members_updated" gorm:"default:0"`
	SyncError      string    `json:"sync_error,omitempty" gorm:"type:text"`
	Configuration  string    `json:"configuration" gorm:"type:jsonb"`
}

External sync status tracking

func (ExternalSyncStatus) TableName

func (ExternalSyncStatus) TableName() string

type ExternalSystemConfig

type ExternalSystemConfig struct {
	SystemType   string                 `json:"system_type"` // "ldap", "active_directory", "okta", etc.
	Config       map[string]interface{} `json:"config"`
	SyncInterval string                 `json:"sync_interval"` // "hourly", "daily", "weekly"
	AutoCreate   bool                   `json:"auto_create"`
	AutoRemove   bool                   `json:"auto_remove"`
}

type ForkRequest

type ForkRequest struct {
	Name      string           `json:"name,omitempty"` // New name for the fork
	OwnerID   uuid.UUID        `json:"owner_id"`       // New owner
	OwnerType models.OwnerType `json:"owner_type"`
}

ForkRequest represents a request to fork a repository

type InsightFilters

type InsightFilters struct {
	StartDate *time.Time `json:"start_date,omitempty"`
	EndDate   *time.Time `json:"end_date,omitempty"`
	Period    Period     `json:"period,omitempty"`
}

InsightFilters for filtering insight data

type InvitationService

type InvitationService interface {
	CreateInvitation(ctx context.Context, orgName, email string, role models.OrganizationRole, inviterID uuid.UUID) (*models.OrganizationInvitation, error)
	AcceptInvitation(ctx context.Context, token string, userID uuid.UUID) error
	DeclineInvitation(ctx context.Context, token string) error
	GetPendingInvitations(ctx context.Context, orgName string) ([]*models.OrganizationInvitation, error)
	CancelInvitation(ctx context.Context, invitationID uuid.UUID) error
}

func NewInvitationService

func NewInvitationService(db *gorm.DB, as ActivityService) InvitationService

type LanguageStatsData

type LanguageStatsData struct {
	Language   string  `json:"language"`
	Count      int     `json:"count"`
	Percentage float64 `json:"percentage"`
}

type MemberActivityMetrics

type MemberActivityMetrics struct {
	Period          string              `json:"period"`
	TotalMembers    int                 `json:"total_members"`
	ActiveMembers   int                 `json:"active_members"`
	MemberGrowth    []MemberGrowthData  `json:"member_growth"`
	ActivityTrends  []ActivityTrendData `json:"activity_trends"`
	TopContributors []MemberSummary     `json:"top_contributors"`
}

type MemberFilters

type MemberFilters struct {
	Role   models.OrganizationRole `json:"role,omitempty"`
	Public *bool                   `json:"public,omitempty"`
	Limit  int                     `json:"limit,omitempty"`
	Offset int                     `json:"offset,omitempty"`
}

type MemberGrowthData

type MemberGrowthData struct {
	Date    time.Time `json:"date"`
	Added   int       `json:"added"`
	Removed int       `json:"removed"`
	Total   int       `json:"total"`
}

type MemberSummary

type MemberSummary struct {
	Username        string    `json:"username"`
	Name            string    `json:"name"`
	Role            string    `json:"role"`
	Commits30d      int       `json:"commits_30d"`
	Issues30d       int       `json:"issues_30d"`
	PullRequests30d int       `json:"pull_requests_30d"`
	LastActiveAt    time.Time `json:"last_active_at"`
}

type MembershipService

type MembershipService interface {
	AddMember(ctx context.Context, orgName, username string, role models.OrganizationRole) (*models.OrganizationMember, error)
	RemoveMember(ctx context.Context, orgName, username string) error
	UpdateMemberRole(ctx context.Context, orgName, username string, role models.OrganizationRole) (*models.OrganizationMember, error)
	GetMembers(ctx context.Context, orgName string, filters MemberFilters) ([]*models.OrganizationMember, error)
	GetMember(ctx context.Context, orgName, username string) (*models.OrganizationMember, error)
	SetMemberVisibility(ctx context.Context, orgName, username string, public bool) error
}

func NewMembershipService

func NewMembershipService(db *gorm.DB, as ActivityService) MembershipService

type MergePullRequestRequest

type MergePullRequestRequest struct {
	CommitTitle   string `json:"commit_title,omitempty"`
	CommitMessage string `json:"commit_message,omitempty"`
	MergeMethod   string `json:"merge_method,omitempty"` // merge, squash, rebase
}

type MetricFilters

type MetricFilters struct {
	Names          []string   `json:"names,omitempty"`
	MetricType     string     `json:"metric_type,omitempty"`
	RepositoryID   *uuid.UUID `json:"repository_id,omitempty"`
	OrganizationID *uuid.UUID `json:"organization_id,omitempty"`
	UserID         *uuid.UUID `json:"user_id,omitempty"`
	Period         Period     `json:"period,omitempty"`
	StartDate      *time.Time `json:"start_date,omitempty"`
	EndDate        *time.Time `json:"end_date,omitempty"`
}

MetricFilters for filtering analytics metrics

type Notification

type Notification struct {
	ID        uuid.UUID   `json:"id"`
	Type      string      `json:"type"`
	Payload   interface{} `json:"payload"`
	Timestamp time.Time   `json:"timestamp"`
}

Notification represents a real-time notification message for a user.

type NotificationService

type NotificationService interface {
	// Subscribe returns a channel to receive notifications for userID and a cancel function.
	Subscribe(userID uuid.UUID) (<-chan Notification, func())
	// Publish sends a notification to all subscribers of userID.
	Publish(userID uuid.UUID, notification Notification)
}

NotificationService manages subscriptions and broadcasts notifications to users.

func NewNotificationService

func NewNotificationService() NotificationService

NewNotificationService creates a new in-memory NotificationService.

type OrganizationActivityStats

type OrganizationActivityStats struct {
	TotalCommits      int64             `json:"total_commits"`
	TotalPullRequests int64             `json:"total_pull_requests"`
	ActivityTrend     []TimeSeriesPoint `json:"activity_trend"`
}

type OrganizationAnalyticsService

type OrganizationAnalyticsService interface {
	GetDashboardMetrics(ctx context.Context, orgName string) (*DashboardMetrics, error)
	GetMemberActivityMetrics(ctx context.Context, orgName string, period string) (*MemberActivityMetrics, error)
	GetRepositoryUsageMetrics(ctx context.Context, orgName string, period string) (*RepositoryUsageMetrics, error)
	GetTeamPerformanceMetrics(ctx context.Context, orgName string, period string) (*TeamPerformanceMetrics, error)
	GetSecurityMetrics(ctx context.Context, orgName string, period string) (*SecurityMetrics, error)
	GetUsageAndCostMetrics(ctx context.Context, orgName string, period string) (*UsageAndCostMetrics, error)
	ExportAnalyticsData(ctx context.Context, orgName string, format string, period string) ([]byte, error)
}

Organization Analytics Service

func NewOrganizationAnalyticsService

func NewOrganizationAnalyticsService(db *gorm.DB) OrganizationAnalyticsService

type OrganizationAuditService

type OrganizationAuditService interface {
	// Enhanced activity retrieval
	GetActivitiesWithFilters(ctx context.Context, orgName string, filters ActivityFilters) (*ActivityResponse, error)
	SearchActivities(ctx context.Context, orgName string, query string, filters ActivityFilters) (*ActivityResponse, error)

	// Export functionality
	ExportActivities(ctx context.Context, orgName string, format string, filters ActivityFilters) ([]byte, error)

	// Retention policy management
	ApplyRetentionPolicy(ctx context.Context, orgName string) error
	GetRetentionPolicyStatus(ctx context.Context, orgName string) (*RetentionPolicyStatus, error)

	// Real-time notifications
	SubscribeToActivity(ctx context.Context, orgName string, userID uuid.UUID, filters ActivitySubscriptionFilters) error
	UnsubscribeFromActivity(ctx context.Context, orgName string, userID uuid.UUID) error

	// Compliance and audit reports
	GenerateComplianceReport(ctx context.Context, orgName string, reportType string, period string) (*ComplianceReport, error)
	GetAuditSummary(ctx context.Context, orgName string, period string) (*AuditSummary, error)
}

Enhanced Activity Service with Search, Filtering, and Export

func NewOrganizationAuditService

func NewOrganizationAuditService(db *gorm.DB) OrganizationAuditService

type OrganizationFilters

type OrganizationFilters struct {
	Limit  int `json:"limit,omitempty"`
	Offset int `json:"offset,omitempty"`
}

type OrganizationInsights

type OrganizationInsights struct {
	Organization    *models.Organization            `json:"organization"`
	Analytics       []*models.OrganizationAnalytics `json:"analytics"`
	MemberStats     *OrganizationMemberStats        `json:"member_stats"`
	RepositoryStats *OrganizationRepositoryStats    `json:"repository_stats"`
	ActivityStats   *OrganizationActivityStats      `json:"activity_stats"`
	ResourceStats   *OrganizationResourceStats      `json:"resource_stats"`
}

Organization Insights

type OrganizationMemberStats

type OrganizationMemberStats struct {
	TotalMembers  int64             `json:"total_members"`
	ActiveMembers int64             `json:"active_members"`
	TotalTeams    int64             `json:"total_teams"`
	MemberTrend   []TimeSeriesPoint `json:"member_trend"`
}

type OrganizationPolicyService

type OrganizationPolicyService interface {
	CreatePolicy(ctx context.Context, orgName string, req CreatePolicyRequest) (*models.OrganizationPolicy, error)
	GetPolicy(ctx context.Context, orgName string, policyID uuid.UUID) (*models.OrganizationPolicy, error)
	UpdatePolicy(ctx context.Context, orgName string, policyID uuid.UUID, req UpdatePolicyRequest) (*models.OrganizationPolicy, error)
	DeletePolicy(ctx context.Context, orgName string, policyID uuid.UUID) error
	ListPolicies(ctx context.Context, orgName string, policyType *models.PolicyType) ([]*models.OrganizationPolicy, error)
	EnforcePolicy(ctx context.Context, orgName string, policyType models.PolicyType, action string, metadata map[string]interface{}) (bool, error)
}

func NewOrganizationPolicyService

func NewOrganizationPolicyService(db *gorm.DB, as ActivityService) OrganizationPolicyService

type OrganizationRepositoryStats

type OrganizationRepositoryStats struct {
	TotalRepositories   int64             `json:"total_repositories"`
	PublicRepositories  int64             `json:"public_repositories"`
	PrivateRepositories int64             `json:"private_repositories"`
	RepositoryTrend     []TimeSeriesPoint `json:"repository_trend"`
}

type OrganizationResourceStats

type OrganizationResourceStats struct {
	StorageUsedMB      int64             `json:"storage_used_mb"`
	BandwidthUsedMB    int64             `json:"bandwidth_used_mb"`
	ComputeTimeMinutes int64             `json:"compute_time_minutes"`
	EstimatedCost      *float64          `json:"estimated_cost"`
	ResourceTrend      []TimeSeriesPoint `json:"resource_trend"`
}

type OrganizationService

type OrganizationService interface {
	Create(ctx context.Context, req CreateOrganizationRequest, ownerID uuid.UUID) (*models.Organization, error)
	Get(ctx context.Context, name string) (*models.Organization, error)
	Update(ctx context.Context, name string, req UpdateOrganizationRequest) (*models.Organization, error)
	Delete(ctx context.Context, name string) error
	List(ctx context.Context, filters OrganizationFilters) ([]*models.Organization, error)
	GetUserOrganizations(ctx context.Context, userID uuid.UUID) ([]*models.Organization, error)
}

Service Interfaces

func NewOrganizationService

func NewOrganizationService(db *gorm.DB, as ActivityService) OrganizationService

type OrganizationSettingsService

type OrganizationSettingsService interface {
	GetSettings(ctx context.Context, orgName string) (*models.OrganizationSettings, error)
	UpdateSettings(ctx context.Context, orgName string, req UpdateOrganizationSettingsRequest) (*models.OrganizationSettings, error)
	ValidateIPAccess(ctx context.Context, orgName string, clientIP string) (bool, error)
	CheckComplianceStatus(ctx context.Context, orgName string) (map[string]bool, error)
}

type OrganizationTemplateService

type OrganizationTemplateService interface {
	CreateTemplate(ctx context.Context, orgName string, req CreateOrgTemplateRequest) (*models.OrganizationTemplate, error)
	GetTemplate(ctx context.Context, orgName string, templateID uuid.UUID) (*models.OrganizationTemplate, error)
	UpdateTemplate(ctx context.Context, orgName string, templateID uuid.UUID, req UpdateTemplateRequest) (*models.OrganizationTemplate, error)
	DeleteTemplate(ctx context.Context, orgName string, templateID uuid.UUID) error
	ListTemplates(ctx context.Context, orgName string, templateType *models.TemplateType) ([]*models.OrganizationTemplate, error)
	UseTemplate(ctx context.Context, orgName string, templateID uuid.UUID) error
}

type OverviewMetrics

type OverviewMetrics struct {
	TotalMembers      int     `json:"total_members"`
	TotalRepositories int     `json:"total_repositories"`
	TotalTeams        int     `json:"total_teams"`
	ActiveMembers30d  int     `json:"active_members_30d"`
	CommitsThisMonth  int     `json:"commits_this_month"`
	IssuesOpen        int     `json:"issues_open"`
	PullRequestsOpen  int     `json:"pull_requests_open"`
	SecurityScore     float64 `json:"security_score"`
}

type PerformanceFilters

type PerformanceFilters struct {
	Methods        []string   `json:"methods,omitempty"`
	Paths          []string   `json:"paths,omitempty"`
	StatusCodes    []int      `json:"status_codes,omitempty"`
	UserID         *uuid.UUID `json:"user_id,omitempty"`
	RepositoryID   *uuid.UUID `json:"repository_id,omitempty"`
	OrganizationID *uuid.UUID `json:"organization_id,omitempty"`
	MinDuration    *int64     `json:"min_duration,omitempty"`
	MaxDuration    *int64     `json:"max_duration,omitempty"`
	StartDate      *time.Time `json:"start_date,omitempty"`
	EndDate        *time.Time `json:"end_date,omitempty"`
	Limit          int        `json:"limit,omitempty"`
	Offset         int        `json:"offset,omitempty"`
}

PerformanceFilters for filtering performance logs

type PerformanceMetrics

type PerformanceMetrics struct {
	AvgResponseTime   *float64          `json:"avg_response_time"`
	P50ResponseTime   *float64          `json:"p50_response_time"`
	P95ResponseTime   *float64          `json:"p95_response_time"`
	P99ResponseTime   *float64          `json:"p99_response_time"`
	TotalRequests     int64             `json:"total_requests"`
	ErrorRate         *float64          `json:"error_rate"`
	ThroughputPerMin  *float64          `json:"throughput_per_min"`
	ResponseTimeTrend []TimeSeriesPoint `json:"response_time_trend"`
	ErrorRateTrend    []TimeSeriesPoint `json:"error_rate_trend"`
}

Performance Metrics

type PerformanceStatistics

type PerformanceStatistics struct {
	AvgResponseTime *float64          `json:"avg_response_time"`
	P95ResponseTime *float64          `json:"p95_response_time"`
	ErrorRate       *float64          `json:"error_rate"`
	ThroughputTrend []TimeSeriesPoint `json:"throughput_trend"`
}

type Period

type Period string

Period represents time periods for analytics

const (
	PeriodHourly  Period = "hourly"
	PeriodDaily   Period = "daily"
	PeriodWeekly  Period = "weekly"
	PeriodMonthly Period = "monthly"
	PeriodYearly  Period = "yearly"
)

type PermissionService

type PermissionService interface {
	GrantRepositoryPermission(ctx context.Context, repoID uuid.UUID, subjectID uuid.UUID, subjectType models.SubjectType, permission models.Permission) error
	RevokeRepositoryPermission(ctx context.Context, repoID uuid.UUID, subjectID uuid.UUID, subjectType models.SubjectType) error
	CheckRepositoryPermission(ctx context.Context, userID uuid.UUID, repoID uuid.UUID, permission models.Permission) (bool, error)
	GetRepositoryPermissions(ctx context.Context, repoID uuid.UUID) ([]*models.RepositoryPermission, error)
	GetUserRepositoryPermission(ctx context.Context, userID uuid.UUID, repoID uuid.UUID) (models.Permission, error)
	CalculateUserPermission(ctx context.Context, userID uuid.UUID, repoID uuid.UUID) (models.Permission, error)
}

Permission Service Interface

func NewPermissionService

func NewPermissionService(db *gorm.DB, as ActivityService) PermissionService

type PluginService

type PluginService interface {
	ListMarketplace(ctx context.Context) ([]*plugin.Manifest, error)
	InstallOrgPlugin(ctx context.Context, org, name string, settings map[string]interface{}) error
	UninstallOrgPlugin(ctx context.Context, org, name string) error
	InstallRepoPlugin(ctx context.Context, owner, repo, name string, settings map[string]interface{}) error
	UninstallRepoPlugin(ctx context.Context, owner, repo, name string) error
}

PluginService defines operations for plugin marketplace and installations.

func NewPluginService

func NewPluginService() PluginService

NewPluginService creates a new in-memory plugin service instance.

type PolicyViolationData

type PolicyViolationData struct {
	PolicyName   string    `json:"policy_name"`
	Count        int       `json:"count"`
	LastOccurred time.Time `json:"last_occurred"`
}

type PolicyViolationEvent

type PolicyViolationEvent struct {
	Timestamp  time.Time `json:"timestamp"`
	User       string    `json:"user"`
	PolicyName string    `json:"policy_name"`
	Violation  string    `json:"violation"`
	Action     string    `json:"action"`
	Resolved   bool      `json:"resolved"`
}

type PullRequestFilter

type PullRequestFilter struct {
	State    *string    `json:"state,omitempty"`
	Head     *string    `json:"head,omitempty"`
	Base     *string    `json:"base,omitempty"`
	UserID   *uuid.UUID `json:"user_id,omitempty"`
	Page     int        `json:"page,omitempty"`
	PageSize int        `json:"page_size,omitempty"`
}

type PullRequestService

type PullRequestService interface {
	Create(ctx context.Context, repoID uuid.UUID, userID uuid.UUID, req CreatePullRequestRequest) (*models.PullRequest, error)
	Get(ctx context.Context, owner, repo string, number int) (*models.PullRequest, error)
	List(ctx context.Context, repoID uuid.UUID, filter PullRequestFilter) ([]*models.PullRequest, error)
	Update(ctx context.Context, id uuid.UUID, req UpdatePullRequestRequest) (*models.PullRequest, error)
	Close(ctx context.Context, id uuid.UUID) error
	Merge(ctx context.Context, id uuid.UUID, req MergePullRequestRequest) error
}

func NewPullRequestService

func NewPullRequestService(db *gorm.DB, gitService git.GitService, repoService RepositoryService, logger *logrus.Logger, repoBasePath string) PullRequestService

type PullRequestStatistics

type PullRequestStatistics struct {
	TotalPullRequests  int64             `json:"total_pull_requests"`
	OpenPullRequests   int64             `json:"open_pull_requests"`
	MergedPullRequests int64             `json:"merged_pull_requests"`
	ClosedPullRequests int64             `json:"closed_pull_requests"`
	AvgTimeToMerge     *float64          `json:"avg_time_to_merge"`
	PRActivity         []TimeSeriesPoint `json:"pr_activity"`
}

type RedisService

type RedisService struct {
	// contains filtered or unexported fields
}

RedisService handles Redis connections and operations

func NewRedisService

func NewRedisService(cfg config.Redis, logger *logrus.Logger) (*RedisService, error)

NewRedisService creates a new Redis service

func (*RedisService) BLPop

func (s *RedisService) BLPop(ctx context.Context, timeout time.Duration, keys ...string) ([]string, error)

BLPop is a blocking version of LPop that waits for items

func (*RedisService) BZPopMax

func (s *RedisService) BZPopMax(ctx context.Context, timeout time.Duration, keys ...string) (*redis.ZWithKey, error)

BZPopMax is a blocking version of ZPopMax

func (*RedisService) Close

func (s *RedisService) Close() error

Close closes the Redis connection

func (*RedisService) Del

func (s *RedisService) Del(ctx context.Context, keys ...string) error

Del deletes keys

func (*RedisService) Exists

func (s *RedisService) Exists(ctx context.Context, keys ...string) (int64, error)

Exists checks if keys exist

func (*RedisService) Expire

func (s *RedisService) Expire(ctx context.Context, key string, expiration time.Duration) error

Expire sets expiration for a key

func (*RedisService) Get

func (s *RedisService) Get(ctx context.Context, key string) (string, error)

Get gets a value by key

func (*RedisService) GetClient

func (s *RedisService) GetClient() *redis.Client

GetClient returns the Redis client

func (*RedisService) HDel

func (s *RedisService) HDel(ctx context.Context, key string, fields ...string) error

HDel deletes fields from a hash

func (*RedisService) HGet

func (s *RedisService) HGet(ctx context.Context, key, field string) (string, error)

HGet gets a field from a hash

func (*RedisService) HGetAll

func (s *RedisService) HGetAll(ctx context.Context, key string) (map[string]string, error)

HGetAll gets all fields from a hash

func (*RedisService) HSet

func (s *RedisService) HSet(ctx context.Context, key string, values ...interface{}) error

HSet sets fields in a hash

func (*RedisService) HealthCheck

func (s *RedisService) HealthCheck(ctx context.Context) error

HealthCheck performs a health check on the Redis connection

func (*RedisService) IsEnabled

func (s *RedisService) IsEnabled() bool

IsEnabled returns whether Redis is enabled

func (*RedisService) LLen

func (s *RedisService) LLen(ctx context.Context, key string) (int64, error)

LLen returns the length of a list

func (*RedisService) LPop

func (s *RedisService) LPop(ctx context.Context, key string) (string, error)

LPop removes and returns the first item from a list

func (*RedisService) LRange

func (s *RedisService) LRange(ctx context.Context, key string, start, stop int64) ([]string, error)

LRange returns a range of items from a list

func (*RedisService) LRem

func (s *RedisService) LRem(ctx context.Context, key string, count int64, value interface{}) error

LRem removes items from a list

func (*RedisService) RPush

func (s *RedisService) RPush(ctx context.Context, key string, values ...interface{}) error

RPush adds items to the right (end) of a list

func (*RedisService) Set

func (s *RedisService) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error

Set sets a key-value pair

func (*RedisService) TxPipeline

func (s *RedisService) TxPipeline() redis.Pipeliner

TxPipeline creates a new transaction pipeline

func (*RedisService) ZAdd

func (s *RedisService) ZAdd(ctx context.Context, key string, members ...redis.Z) error

ZAdd adds items to a sorted set with scores (for priority)

func (*RedisService) ZCard

func (s *RedisService) ZCard(ctx context.Context, key string) (int64, error)

ZCard returns the number of items in a sorted set

func (*RedisService) ZPopMax

func (s *RedisService) ZPopMax(ctx context.Context, key string, count ...int64) ([]redis.Z, error)

ZPopMax removes and returns the highest scored item from a sorted set

func (*RedisService) ZRange

func (s *RedisService) ZRange(ctx context.Context, key string, start, stop int64) ([]string, error)

ZRange returns a range of items from a sorted set

func (*RedisService) ZRangeWithScores

func (s *RedisService) ZRangeWithScores(ctx context.Context, key string, start, stop int64) ([]redis.Z, error)

ZRangeWithScores returns a range of items with scores from a sorted set

func (*RedisService) ZRem

func (s *RedisService) ZRem(ctx context.Context, key string, members ...interface{}) error

ZRem removes items from a sorted set

type Report

type Report struct {
	Type        ReportType  `json:"type"`
	TargetID    *uuid.UUID  `json:"target_id,omitempty"`
	Period      Period      `json:"period"`
	StartDate   time.Time   `json:"start_date"`
	EndDate     time.Time   `json:"end_date"`
	GeneratedAt time.Time   `json:"generated_at"`
	Data        interface{} `json:"data"`
}

type ReportFilters

type ReportFilters struct {
	Type           ReportType `json:"type"`
	TargetID       *uuid.UUID `json:"target_id,omitempty"`
	StartDate      *time.Time `json:"start_date,omitempty"`
	EndDate        *time.Time `json:"end_date,omitempty"`
	Period         Period     `json:"period,omitempty"`
	IncludeTrends  bool       `json:"include_trends,omitempty"`
	IncludeDetails bool       `json:"include_details,omitempty"`
}

type ReportType

type ReportType string

Report types

const (
	ReportTypeRepository   ReportType = "repository"
	ReportTypeUser         ReportType = "user"
	ReportTypeOrganization ReportType = "organization"
	ReportTypeSystem       ReportType = "system"
	ReportTypePerformance  ReportType = "performance"
)

type RepositoryDocument

type RepositoryDocument struct {
	ID              string    `json:"id"`
	Name            string    `json:"name"`
	FullName        string    `json:"full_name"`
	Description     string    `json:"description"`
	Language        string    `json:"language"`
	Topics          []string  `json:"topics"`
	OwnerID         string    `json:"owner_id"`
	OwnerName       string    `json:"owner_name"`
	OwnerType       string    `json:"owner_type"`
	Visibility      string    `json:"visibility"`
	DefaultBranch   string    `json:"default_branch"`
	IsTemplate      bool      `json:"is_template"`
	IsArchived      bool      `json:"is_archived"`
	IsFork          bool      `json:"is_fork"`
	HasWiki         bool      `json:"has_wiki"`
	HasPages        bool      `json:"has_pages"`
	StarsCount      int       `json:"stars_count"`
	ForksCount      int       `json:"forks_count"`
	WatchersCount   int       `json:"watchers_count"`
	Size            int       `json:"size"`
	OpenIssuesCount int       `json:"open_issues_count"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
	PushedAt        time.Time `json:"pushed_at"`
}

type RepositoryFilters

type RepositoryFilters struct {
	OwnerID    *uuid.UUID         `json:"owner_id,omitempty"`
	OwnerType  *models.OwnerType  `json:"owner_type,omitempty"`
	Visibility *models.Visibility `json:"visibility,omitempty"`
	IsTemplate *bool              `json:"is_template,omitempty"`
	IsArchived *bool              `json:"is_archived,omitempty"`
	IsFork     *bool              `json:"is_fork,omitempty"`
	Search     string             `json:"search,omitempty"` // Search in name and description
	Language   string             `json:"language,omitempty"`
	Sort       string             `json:"sort,omitempty"`      // name, created, updated, pushed, stars, forks
	Direction  string             `json:"direction,omitempty"` // asc, desc
	Page       int                `json:"page,omitempty"`
	PerPage    int                `json:"per_page,omitempty"`
}

RepositoryFilters represents filters for listing repositories

type RepositoryGrowthData

type RepositoryGrowthData struct {
	Date    time.Time `json:"date"`
	Created int       `json:"created"`
	Deleted int       `json:"deleted"`
	Total   int       `json:"total"`
}

type RepositoryInsights

type RepositoryInsights struct {
	Repository       *models.Repository            `json:"repository"`
	Analytics        []*models.RepositoryAnalytics `json:"analytics"`
	CodeStats        *CodeStatistics               `json:"code_stats"`
	ActivityStats    *ActivityStatistics           `json:"activity_stats"`
	ContributorStats *ContributorStatistics        `json:"contributor_stats"`

	PullRequestStats *PullRequestStatistics `json:"pull_request_stats"`
	PerformanceStats *PerformanceStatistics `json:"performance_stats"`
}

Repository Insights

type RepositoryService

type RepositoryService interface {
	// Repository CRUD operations
	Create(ctx context.Context, req CreateRepositoryRequest) (*models.Repository, error)
	Get(ctx context.Context, owner, name string) (*models.Repository, error)
	GetByID(ctx context.Context, id uuid.UUID) (*models.Repository, error)
	Update(ctx context.Context, id uuid.UUID, req UpdateRepositoryRequest) (*models.Repository, error)
	Delete(ctx context.Context, id uuid.UUID) error
	List(ctx context.Context, filters RepositoryFilters) ([]*models.Repository, int64, error)

	// Repository operations
	Fork(ctx context.Context, id uuid.UUID, req ForkRequest) (*models.Repository, error)
	Transfer(ctx context.Context, id uuid.UUID, req TransferRequest) error
	Archive(ctx context.Context, id uuid.UUID) error
	Unarchive(ctx context.Context, id uuid.UUID) error

	// Git operations
	InitializeGitRepository(ctx context.Context, repoID uuid.UUID) error
	GetRepositoryPath(ctx context.Context, repoID uuid.UUID) (string, error)
	SyncCommits(ctx context.Context, repoID uuid.UUID) error

	// Statistics and language detection
	UpdateRepositoryStats(ctx context.Context, repoID uuid.UUID) error
	GetLanguages(ctx context.Context, repoID uuid.UUID) (map[string]git.LanguageStats, error)
	GetRepositoryStatistics(ctx context.Context, repoID uuid.UUID) (*git.RepositoryStats, error)

	// Git hooks management
	CreateGitHook(ctx context.Context, repoID uuid.UUID, req CreateGitHookRequest) (*models.GitHook, error)
	UpdateGitHook(ctx context.Context, hookID uuid.UUID, req UpdateGitHookRequest) (*models.GitHook, error)
	DeleteGitHook(ctx context.Context, hookID uuid.UUID) error
	GetGitHooks(ctx context.Context, repoID uuid.UUID) ([]*models.GitHook, error)

	// Repository templates
	CreateTemplate(ctx context.Context, repoID uuid.UUID, req CreateTemplateRequest) (*models.RepositoryTemplate, error)
	GetTemplates(ctx context.Context, filters TemplateFilters) ([]*models.RepositoryTemplate, error)
	UseTemplate(ctx context.Context, templateID uuid.UUID, req CreateRepositoryRequest) (*models.Repository, error)
}

RepositoryService provides repository management operations

func NewRepositoryService

func NewRepositoryService(db *gorm.DB, gitService git.GitService, logger *logrus.Logger, repoBasePath string) RepositoryService

NewRepositoryService creates a new repository service

type RepositoryStorageUsage

type RepositoryStorageUsage struct {
	Name    string  `json:"name"`
	SizeGB  float64 `json:"size_gb"`
	Percent float64 `json:"percent"`
}

type RepositorySummary

type RepositorySummary struct {
	Name           string    `json:"name"`
	Language       string    `json:"language"`
	Stars          int       `json:"stars"`
	Forks          int       `json:"forks"`
	Contributors   int       `json:"contributors"`
	Commits30d     int       `json:"commits_30d"`
	Issues30d      int       `json:"issues_30d"`
	LastActivityAt time.Time `json:"last_activity_at"`
}

type RepositoryUsageMetrics

type RepositoryUsageMetrics struct {
	Period             string                 `json:"period"`
	TotalRepositories  int                    `json:"total_repositories"`
	ActiveRepositories int                    `json:"active_repositories"`
	RepositoryGrowth   []RepositoryGrowthData `json:"repository_growth"`
	LanguageStats      []LanguageStatsData    `json:"language_stats"`
	TopRepositories    []RepositorySummary    `json:"top_repositories"`
}

type RequiredPullRequestReviews

type RequiredPullRequestReviews struct {
	RequiredApprovingReviewCount int  `json:"required_approving_review_count"`
	DismissStaleReviews          bool `json:"dismiss_stale_reviews"`
	RequireCodeOwnerReviews      bool `json:"require_code_owner_reviews"`
	RestrictPushesToCodeOwners   bool `json:"restrict_pushes_to_code_owners"`
}

RequiredPullRequestReviews represents required pull request reviews for branch protection

type RequiredStatusChecks

type RequiredStatusChecks struct {
	Strict   bool     `json:"strict"`
	Contexts []string `json:"contexts"`
}

RequiredStatusChecks represents required status checks for branch protection

type RetentionPolicyStatus

type RetentionPolicyStatus struct {
	CurrentPolicy        string    `json:"current_policy"`
	RetentionDays        int       `json:"retention_days"`
	TotalActivities      int       `json:"total_activities"`
	OldestActivity       time.Time `json:"oldest_activity"`
	LastCleanup          time.Time `json:"last_cleanup"`
	NextCleanup          time.Time `json:"next_cleanup"`
	ActivitiesForCleanup int       `json:"activities_for_cleanup"`
}

type SearchFilter

type SearchFilter struct {
	Query     string     `json:"query"`
	Type      string     `json:"type"`      // user, repository, organization, commit, code
	Sort      string     `json:"sort"`      // relevance, created, updated, stars, forks
	Direction string     `json:"direction"` // asc, desc
	Page      int        `json:"page"`
	PerPage   int        `json:"per_page"`
	UserID    *uuid.UUID `json:"user_id,omitempty"` // For permission filtering
}

SearchFilter represents search filtering options

type SearchResults

type SearchResults struct {
	Users         []models.User         `json:"users"`
	Repositories  []models.Repository   `json:"repositories"`
	Organizations []models.Organization `json:"organizations"`
	Commits       []models.Commit       `json:"commits"`
	TotalCount    int64                 `json:"total_count"`
}

SearchResults represents the aggregated search results

type SearchService

type SearchService struct {
	// contains filtered or unexported fields
}

func NewSearchService

func NewSearchService(db *gorm.DB, elasticsearch interface{}, logger *logrus.Logger) *SearchService

func (*SearchService) GlobalSearch

func (s *SearchService) GlobalSearch(ctx context.Context, filter SearchFilter) (*SearchResults, error)

GlobalSearch performs a global search across all content types

type SecurityAlert

type SecurityAlert struct {
	Type        string    `json:"type"`
	Severity    string    `json:"severity"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Repository  string    `json:"repository"`
	CreatedAt   time.Time `json:"created_at"`
}

type SecurityEvent

type SecurityEvent struct {
	Timestamp   time.Time `json:"timestamp"`
	EventType   string    `json:"event_type"`
	User        string    `json:"user"`
	Description string    `json:"description"`
	Severity    string    `json:"severity"`
	IPAddress   string    `json:"ip_address"`
	Location    string    `json:"location"`
}

type SecurityInsights

type SecurityInsights struct {
	SuspiciousActivities int            `json:"suspicious_activities"`
	FailedAttempts       int            `json:"failed_attempts"`
	UnusualLocations     []string       `json:"unusual_locations"`
	OffHoursAccess       int            `json:"off_hours_access"`
	RiskDistribution     map[string]int `json:"risk_distribution"`
}

type SecurityMetrics

type SecurityMetrics struct {
	Period               string                `json:"period"`
	SecurityScore        float64               `json:"security_score"`
	VulnerabilitiesFound int                   `json:"vulnerabilities_found"`
	VulnerabilitiesFixed int                   `json:"vulnerabilities_fixed"`
	SecurityAlerts       []SecurityAlert       `json:"security_alerts"`
	ComplianceStatus     map[string]bool       `json:"compliance_status"`
	PolicyViolations     []PolicyViolationData `json:"policy_violations"`
}

type StorageUsageMetrics

type StorageUsageMetrics struct {
	TotalUsedGB     float64                  `json:"total_used_gb"`
	TotalLimitGB    float64                  `json:"total_limit_gb"`
	UsagePercent    float64                  `json:"usage_percent"`
	TopRepositories []RepositoryStorageUsage `json:"top_repositories"`
}

type SystemInsights

type SystemInsights struct {
	Analytics        []*models.SystemAnalytics `json:"analytics"`
	UserStats        *SystemUserStats          `json:"user_stats"`
	RepositoryStats  *SystemRepositoryStats    `json:"repository_stats"`
	PerformanceStats *SystemPerformanceStats   `json:"performance_stats"`
	ResourceStats    *SystemResourceStats      `json:"resource_stats"`
}

System Insights

type SystemPerformanceStats

type SystemPerformanceStats struct {
	AvgResponseTime  *float64          `json:"avg_response_time"`
	P95ResponseTime  *float64          `json:"p95_response_time"`
	ErrorRate        *float64          `json:"error_rate"`
	Uptime           *float64          `json:"uptime"`
	PerformanceTrend []TimeSeriesPoint `json:"performance_trend"`
}

type SystemRepositoryStats

type SystemRepositoryStats struct {
	TotalRepositories   int64             `json:"total_repositories"`
	PublicRepositories  int64             `json:"public_repositories"`
	PrivateRepositories int64             `json:"private_repositories"`
	TotalOrganizations  int64             `json:"total_organizations"`
	RepositoryTrend     []TimeSeriesPoint `json:"repository_trend"`
}

type SystemResourceStats

type SystemResourceStats struct {
	CPUUsage      *float64          `json:"cpu_usage"`
	MemoryUsage   *float64          `json:"memory_usage"`
	DiskUsage     *float64          `json:"disk_usage"`
	NetworkInMB   int64             `json:"network_in_mb"`
	NetworkOutMB  int64             `json:"network_out_mb"`
	ResourceTrend []TimeSeriesPoint `json:"resource_trend"`
}

type SystemUserStats

type SystemUserStats struct {
	TotalUsers       int64             `json:"total_users"`
	ActiveUsers      int64             `json:"active_users"`
	NewRegistrations int64             `json:"new_registrations"`
	ChurnRate        *float64          `json:"churn_rate"`
	UserTrend        []TimeSeriesPoint `json:"user_trend"`
}

type TargetDetails

type TargetDetails struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Description string `json:"description,omitempty"`
}

type TeamActivity

type TeamActivity struct {
	ActivityType string                 `json:"activity_type"`
	ActorID      uuid.UUID              `json:"actor_id"`
	Metadata     map[string]interface{} `json:"metadata"`
	Timestamp    time.Time              `json:"timestamp"`
}

type TeamActivityData

type TeamActivityData struct {
	TeamName   string    `json:"team_name"`
	Members    int       `json:"members"`
	Commits30d int       `json:"commits_30d"`
	Issues30d  int       `json:"issues_30d"`
	PRs30d     int       `json:"prs_30d"`
	LastActive time.Time `json:"last_active"`
}

type TeamFilters

type TeamFilters struct {
	Privacy *models.TeamPrivacy `json:"privacy,omitempty"`
	Limit   int                 `json:"limit,omitempty"`
	Offset  int                 `json:"offset,omitempty"`
}

type TeamMembershipService

type TeamMembershipService interface {
	AddMember(ctx context.Context, orgName, teamName, username string, role models.TeamRole) (*models.TeamMember, error)
	RemoveMember(ctx context.Context, orgName, teamName, username string) error
	UpdateMemberRole(ctx context.Context, orgName, teamName, username string, role models.TeamRole) (*models.TeamMember, error)
	GetMembers(ctx context.Context, orgName, teamName string) ([]*models.TeamMember, error)
	GetUserTeams(ctx context.Context, orgName, username string) ([]*models.Team, error)
}

func NewTeamMembershipService

func NewTeamMembershipService(db *gorm.DB, as ActivityService) TeamMembershipService

type TeamPerformanceData

type TeamPerformanceData struct {
	TeamName        string    `json:"team_name"`
	Period          string    `json:"period"`
	MemberCount     int       `json:"member_count"`
	CommitsCount    int       `json:"commits_count"`
	IssuesResolved  int       `json:"issues_resolved"`
	PullRequests    int       `json:"pull_requests"`
	CodeReviews     int       `json:"code_reviews"`
	AvgResponseTime float64   `json:"avg_response_time_hours"`
	Productivity    float64   `json:"productivity_score"`
	LastUpdated     time.Time `json:"last_updated"`
}

type TeamPerformanceMetrics

type TeamPerformanceMetrics struct {
	Period       string             `json:"period"`
	TotalTeams   int                `json:"total_teams"`
	ActiveTeams  int                `json:"active_teams"`
	TeamActivity []TeamActivityData `json:"team_activity"`
	TeamSizes    []TeamSizeData     `json:"team_sizes"`
}

type TeamService

type TeamService interface {
	Create(ctx context.Context, orgName string, req CreateTeamRequest) (*models.Team, error)
	Get(ctx context.Context, orgName, teamName string) (*models.Team, error)
	Update(ctx context.Context, orgName, teamName string, req UpdateTeamRequest) (*models.Team, error)
	Delete(ctx context.Context, orgName, teamName string) error
	List(ctx context.Context, orgName string, filters TeamFilters) ([]*models.Team, error)
	GetTeamHierarchy(ctx context.Context, orgName string) ([]*models.Team, error)
}

Service Interfaces

func NewTeamService

func NewTeamService(db *gorm.DB, as ActivityService) TeamService

type TeamSizeData

type TeamSizeData struct {
	TeamName string `json:"team_name"`
	Size     int    `json:"size"`
}

type TeamTemplateService

type TeamTemplateService interface {
	CreateTeamFromTemplate(ctx context.Context, orgName string, templateID uuid.UUID, req CreateTeamFromTemplateRequest) (*models.Team, error)
	GetTeamTemplates(ctx context.Context, orgName string) ([]*models.OrganizationTemplate, error)
	SyncWithExternalSystem(ctx context.Context, orgName, teamName string, externalSystemConfig ExternalSystemConfig) error
	GetTeamPerformanceMetrics(ctx context.Context, orgName, teamName string, period string) (*TeamPerformanceData, error)
	TrackTeamActivity(ctx context.Context, orgName, teamName string, activity TeamActivity) error
}

Enhanced Team Service with Templates and Performance Tracking

func NewTeamTemplateService

func NewTeamTemplateService(db *gorm.DB, as ActivityService, ts TeamService) TeamTemplateService

type TemplateFilters

type TemplateFilters struct {
	Category   string `json:"category,omitempty"`
	IsFeatured *bool  `json:"is_featured,omitempty"`
	IsPublic   *bool  `json:"is_public,omitempty"`
	Search     string `json:"search,omitempty"`    // Search in name and description
	Sort       string `json:"sort,omitempty"`      // name, created, usage_count
	Direction  string `json:"direction,omitempty"` // asc, desc
	Page       int    `json:"page,omitempty"`
	PerPage    int    `json:"per_page,omitempty"`
}

TemplateFilters represents filters for listing repository templates

type TimeSeriesPoint

type TimeSeriesPoint struct {
	Timestamp time.Time `json:"timestamp"`
	Value     float64   `json:"value"`
}

Common types

type TransferRequest

type TransferRequest struct {
	NewOwnerID   uuid.UUID        `json:"new_owner_id"`
	NewOwnerType models.OwnerType `json:"new_owner_type"`
}

TransferRequest represents a request to transfer a repository

type UpdateBranchProtectionRequest

type UpdateBranchProtectionRequest struct {
	Pattern                    *string                     `json:"pattern,omitempty"`
	RequiredStatusChecks       *RequiredStatusChecks       `json:"required_status_checks,omitempty"`
	EnforceAdmins              *bool                       `json:"enforce_admins,omitempty"`
	RequiredPullRequestReviews *RequiredPullRequestReviews `json:"required_pull_request_reviews,omitempty"`
	Restrictions               *BranchRestrictions         `json:"restrictions,omitempty"`
}

UpdateBranchProtectionRequest represents a request to update a branch protection rule

type UpdateCustomRoleRequest

type UpdateCustomRoleRequest struct {
	Name        *string                `json:"name,omitempty"`
	Description *string                `json:"description,omitempty"`
	Permissions map[string]interface{} `json:"permissions,omitempty"`
	Color       *string                `json:"color,omitempty"`
}

type UpdateGitHookRequest

type UpdateGitHookRequest struct {
	Script    *string `json:"script,omitempty"`
	Language  *string `json:"language,omitempty"`
	IsEnabled *bool   `json:"is_enabled,omitempty"`
	Order     *int    `json:"order,omitempty"`
}

UpdateGitHookRequest represents a request to update a Git hook

type UpdateOrganizationRequest

type UpdateOrganizationRequest struct {
	DisplayName  *string `json:"display_name,omitempty"`
	Description  *string `json:"description,omitempty"`
	AvatarURL    *string `json:"avatar_url,omitempty"`
	Website      *string `json:"website,omitempty"`
	Location     *string `json:"location,omitempty"`
	Email        *string `json:"email,omitempty"`
	BillingEmail *string `json:"billing_email,omitempty"`
}

type UpdateOrganizationSettingsRequest

type UpdateOrganizationSettingsRequest struct {
	// Branding
	PrimaryColor   *string `json:"primary_color,omitempty"`
	SecondaryColor *string `json:"secondary_color,omitempty"`
	LogoURL        *string `json:"logo_url,omitempty"`
	CustomCSS      *string `json:"custom_css,omitempty"`

	// Security Settings
	RequireTwoFactor *bool    `json:"require_two_factor,omitempty"`
	AllowedIPRanges  []string `json:"allowed_ip_ranges,omitempty"`
	SSOProvider      *string  `json:"sso_provider,omitempty"`
	SSOConfiguration *string  `json:"sso_configuration,omitempty"`
	SessionTimeout   *int     `json:"session_timeout,omitempty"`

	// Repository Settings
	DefaultVisibility         *string `json:"default_visibility,omitempty"`
	AllowPrivateRepos         *bool   `json:"allow_private_repos,omitempty"`
	AllowInternalRepos        *bool   `json:"allow_internal_repos,omitempty"`
	AllowForking              *bool   `json:"allow_forking,omitempty"`
	AllowOutsideCollaborators *bool   `json:"allow_outside_collaborators,omitempty"`

	// Backup and Recovery
	BackupEnabled   *bool   `json:"backup_enabled,omitempty"`
	BackupFrequency *string `json:"backup_frequency,omitempty"`
	RetentionDays   *int    `json:"retention_days,omitempty"`
}

type UpdatePolicyRequest

type UpdatePolicyRequest struct {
	Name          *string                `json:"name,omitempty"`
	Description   *string                `json:"description,omitempty"`
	Configuration map[string]interface{} `json:"configuration,omitempty"`
	Enabled       *bool                  `json:"enabled,omitempty"`
	Enforcement   *string                `json:"enforcement,omitempty"`
}

type UpdatePullRequestRequest

type UpdatePullRequestRequest struct {
	Title *string `json:"title,omitempty"`
	Body  *string `json:"body,omitempty"`
	State *string `json:"state,omitempty"`
}

type UpdateRepositoryRequest

type UpdateRepositoryRequest struct {
	Name          *string            `json:"name,omitempty"`
	Description   *string            `json:"description,omitempty"`
	DefaultBranch *string            `json:"default_branch,omitempty"`
	Visibility    *models.Visibility `json:"visibility,omitempty"`
	IsTemplate    *bool              `json:"is_template,omitempty"`
	HasIssues     *bool              `json:"has_issues,omitempty"`

	HasWiki             *bool `json:"has_wiki,omitempty"`
	HasDownloads        *bool `json:"has_downloads,omitempty"`
	AllowMergeCommit    *bool `json:"allow_merge_commit,omitempty"`
	AllowSquashMerge    *bool `json:"allow_squash_merge,omitempty"`
	AllowRebaseMerge    *bool `json:"allow_rebase_merge,omitempty"`
	DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"`
}

UpdateRepositoryRequest represents a request to update a repository

type UpdateTeamRequest

type UpdateTeamRequest struct {
	Name         *string             `json:"name,omitempty"`
	Description  *string             `json:"description,omitempty"`
	Privacy      *models.TeamPrivacy `json:"privacy,omitempty"`
	ParentTeamID *uuid.UUID          `json:"parent_team_id,omitempty"`
}

type UpdateTemplateRequest

type UpdateTemplateRequest struct {
	Name          *string                `json:"name,omitempty"`
	Description   *string                `json:"description,omitempty"`
	Configuration map[string]interface{} `json:"configuration,omitempty"`
}

type UsageAndCostMetrics

type UsageAndCostMetrics struct {
	Period         string                 `json:"period"`
	BillingPlan    string                 `json:"billing_plan"`
	SeatCount      int                    `json:"seat_count"`
	StorageUsage   *StorageUsageMetrics   `json:"storage_usage"`
	BandwidthUsage *BandwidthUsageMetrics `json:"bandwidth_usage"`
	EstimatedCost  float64                `json:"estimated_cost"`
	CostBreakdown  []CostBreakdownData    `json:"cost_breakdown"`
	UsageTrends    []UsageTrendData       `json:"usage_trends"`
}

type UsageTrendData

type UsageTrendData struct {
	Date        time.Time `json:"date"`
	Storage     float64   `json:"storage_gb"`
	Bandwidth   float64   `json:"bandwidth_gb"`
	ActiveUsers int       `json:"active_users"`
}

type UserActivityStats

type UserActivityStats struct {
	TotalLogins    int64             `json:"total_logins"`
	TotalSessions  int64             `json:"total_sessions"`
	AvgSessionTime *float64          `json:"avg_session_time"`
	TotalPageViews int64             `json:"total_page_views"`
	ActivityTrend  []TimeSeriesPoint `json:"activity_trend"`
}

type UserContributionStats

type UserContributionStats struct {
	TotalCommits      int64             `json:"total_commits"`
	TotalPullRequests int64             `json:"total_pull_requests"`
	TotalComments     int64             `json:"total_comments"`
	ContributionTrend []TimeSeriesPoint `json:"contribution_trend"`
}

type UserDetails

type UserDetails struct {
	Username  string `json:"username"`
	Name      string `json:"name"`
	Email     string `json:"email"`
	AvatarURL string `json:"avatar_url"`
}

type UserDocument

type UserDocument struct {
	ID        string    `json:"id"`
	Username  string    `json:"username"`
	FullName  string    `json:"full_name"`
	Email     string    `json:"email"`
	Location  string    `json:"location"`
	Website   string    `json:"website"`
	Bio       string    `json:"bio"`
	Company   string    `json:"company"`
	AvatarURL string    `json:"avatar_url"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Minimal document types without issues

type UserInsights

type UserInsights struct {
	User              *models.User            `json:"user"`
	Analytics         []*models.UserAnalytics `json:"analytics"`
	ActivityStats     *UserActivityStats      `json:"activity_stats"`
	ContributionStats *UserContributionStats  `json:"contribution_stats"`
	RepositoryStats   *UserRepositoryStats    `json:"repository_stats"`
}

User Insights

type UserRepositoryStats

type UserRepositoryStats struct {
	TotalRepositories int64             `json:"total_repositories"`
	TotalStars        int64             `json:"total_stars"`
	TotalForks        int64             `json:"total_forks"`
	RepositoryTrend   []TimeSeriesPoint `json:"repository_trend"`
}

type WebhookDeliveryService

type WebhookDeliveryService struct {
	// contains filtered or unexported fields
}

WebhookDeliveryService handles webhook delivery, retry logic, and management

func NewWebhookDeliveryService

func NewWebhookDeliveryService(db *gorm.DB, logger *logrus.Logger) *WebhookDeliveryService

NewWebhookDeliveryService creates a new webhook delivery service

func (*WebhookDeliveryService) CreateWebhook

func (s *WebhookDeliveryService) CreateWebhook(ctx context.Context, repositoryID uuid.UUID, name, url, secret string, events []string, contentType string, insecureSSL, active bool) (*models.Webhook, error)

CreateWebhook creates a new webhook configuration

func (*WebhookDeliveryService) DeleteWebhook

func (s *WebhookDeliveryService) DeleteWebhook(ctx context.Context, webhookID uuid.UUID) error

DeleteWebhook deletes a webhook

func (*WebhookDeliveryService) DeliverWebhook

func (s *WebhookDeliveryService) DeliverWebhook(ctx context.Context, webhook models.Webhook, eventType string, payload map[string]interface{}) error

DeliverWebhook delivers a single webhook

func (*WebhookDeliveryService) GetDeliveries

func (s *WebhookDeliveryService) GetDeliveries(ctx context.Context, webhookID uuid.UUID, limit, offset int) ([]models.WebhookDelivery, error)

GetDeliveries gets webhook deliveries for a webhook

func (*WebhookDeliveryService) GetWebhook

func (s *WebhookDeliveryService) GetWebhook(ctx context.Context, webhookID uuid.UUID) (*models.Webhook, error)

GetWebhook retrieves a webhook by ID

func (*WebhookDeliveryService) ListWebhooks

func (s *WebhookDeliveryService) ListWebhooks(ctx context.Context, repositoryID uuid.UUID) ([]models.Webhook, error)

ListWebhooks lists all webhooks for a repository

func (*WebhookDeliveryService) PingWebhook

func (s *WebhookDeliveryService) PingWebhook(ctx context.Context, webhookID uuid.UUID) error

PingWebhook sends a ping event to test webhook

func (*WebhookDeliveryService) RetryFailedDeliveries

func (s *WebhookDeliveryService) RetryFailedDeliveries(ctx context.Context) error

RetryFailedDeliveries retries failed webhook deliveries that are due for retry

func (*WebhookDeliveryService) TriggerWebhooks

func (s *WebhookDeliveryService) TriggerWebhooks(ctx context.Context, repositoryID uuid.UUID, eventType string, payload map[string]interface{}) error

TriggerWebhooks triggers all active webhooks for a repository for a specific event

func (*WebhookDeliveryService) UpdateWebhook

func (s *WebhookDeliveryService) UpdateWebhook(ctx context.Context, webhookID uuid.UUID, updates map[string]interface{}) (*models.Webhook, error)

UpdateWebhook updates an existing webhook

func (*WebhookDeliveryService) VerifySignature

func (s *WebhookDeliveryService) VerifySignature(secret, signature string, payload []byte) bool

VerifySignature verifies webhook signature

type WebhookPayload

type WebhookPayload struct {
	Event      string                 `json:"event"`
	Action     string                 `json:"action,omitempty"`
	Repository map[string]interface{} `json:"repository"`
	Sender     map[string]interface{} `json:"sender,omitempty"`
	Data       map[string]interface{} `json:"data,omitempty"`
	Timestamp  time.Time              `json:"timestamp"`
}

WebhookPayload represents the structure of webhook payload

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL