Files
kra-new/internal/biz/business/performance_models.go
T

140 lines
4.0 KiB
Go

package business
import (
"context"
"time"
)
type PerformanceMetrics struct {
Open, Effective int64
Pay string
}
type PerformancePeriod struct{ Key, Label, Begin, End string }
type PerformanceFilter struct {
Year, BeginMonth, EndMonth int
Name string
Level *int
GroupID *uint64
SortField string
Ascending bool
ForManagement bool
}
type PerformanceRow struct {
Member *BusinessMember
Total PerformanceMetrics
Rate *string
Periods map[string]PerformanceMetrics
Goals map[string]*PerformanceGoal
DescendantCount int
}
type PerformanceGroupRow struct {
Group *BusinessGroup
Total, UniqueTotal PerformanceMetrics
Periods, UniquePeriods map[string]PerformanceMetrics
Members []*PerformanceRow
Goals map[string]*PerformanceGoal
}
type PerformancePage struct {
MatrixTotal PerformanceMetrics
MatrixRate *string
MatrixTrend map[string]PerformanceMetrics
Prior PerformanceMetrics
Rows []*PerformanceRow
Groups []*PerformanceGroupRow
Total PerformanceMetrics
Rate *string
ProductiveMembers int64
Periods []PerformancePeriod
Trend map[string]PerformanceMetrics
Begin, End, Granularity string
Settings OtherSettings
Available bool
}
type PerformanceChannel struct {
ChannelKey
ContributorID uint
ContributorName string
OwnerID uint
OwnerIDs []uint
Account, Name, OwnerName string
CreatedAt, QualifiedAt *int64
WindowPay, PeriodPay string
}
type PerformanceCash struct {
ChannelKey
OwnerIDs []uint
Date, Pay string
}
type PerformanceFacts struct {
Channels []*PerformanceChannel
Cash []PerformanceCash
Available bool
}
type PerformanceRepo interface {
Facts(context.Context, UserScope, []uint, []string, time.Time, time.Time) (*PerformanceFacts, error)
Details(context.Context, UserScope, PerformanceDetailSelection, []string, time.Time, time.Time, string, int, int) ([]*PerformanceChannel, int64, error)
}
// ContributorIDs requests one row per contributing member and channel.
// Without contributors the same channels are returned as a deduplicated union.
type PerformanceDetailSelection struct {
OwnerIDs []uint
ContributorIDs []uint
}
type PerformanceGoal struct {
Kind string
TargetID uint64
Month string
Open, Effective, Amount *int64
UpdatedBy uint
UpdatedAt time.Time
}
type GoalRepo interface {
List(context.Context, string, string) ([]*PerformanceGoal, error)
Save(context.Context, *PerformanceGoal) error
}
type GoalMonth struct {
Available bool
Month string
Goal *PerformanceGoal
Actual PerformanceMetrics
Status string
Missing int
CanEdit bool
}
type GoalPage struct {
Kind, Name string
TargetID uint64
CanEdit bool
Months []GoalMonth
MemberGoals map[string]PerformanceMetrics
}
type EffectivenessCandidate struct {
ChannelKey
CreatedAt, PreviousAt *int64
PreviousPay string
}
type EffectivenessCharge struct {
ChannelKey
PaidAt int64
Amount string
}
type EffectivenessResult struct {
ChannelKey
QualifiedAt *int64
WindowPay string
Complete bool
}
type EffectivenessState struct {
RuleKey string
Revision uint64
BuiltAt time.Time
}
type EffectivenessRepo interface {
State(context.Context) (*EffectivenessState, error)
Candidates(context.Context, string, int64, int64, bool) ([]*EffectivenessCandidate, error)
Charges(context.Context, []*EffectivenessCandidate, int64, int64, bool, func(EffectivenessCharge) error) error
Publish(context.Context, *EffectivenessState, OtherSettings, string, []EffectivenessResult, bool) (*OtherSettings, error)
}