RezinaLMS-BackEnd/internal/domain/profile_field_option.go
Yared Yemane 3b08a07c85 Add subscription behaviour analytics and clean profile breakdowns.
Extend the analytics dashboard with live subscription snapshots, renewal/resubscribe metrics, and field-options normalization so Unknown and invalid profile values aggregate as Other. Also include exam_prep in the learner progress summary.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-29 08:46:30 -07:00

80 lines
2.0 KiB
Go

package domain
import (
"errors"
"time"
)
const (
ProfileFieldOptionStatusActive = "ACTIVE"
ProfileFieldOptionStatusInactive = "INACTIVE"
)
var (
ErrInvalidFieldKey = errors.New("invalid field key")
ErrInvalidOptionCode = errors.New("invalid field option code")
ErrFieldOptionNotFound = errors.New("field option not found")
)
// Deprecated aliases for internal references during transition.
var (
ErrInvalidProfileFieldKey = ErrInvalidFieldKey
ErrInvalidProfileFieldOptionCode = ErrInvalidOptionCode
ErrProfileFieldOptionNotFound = ErrFieldOptionNotFound
)
const (
ProfileFieldEducationLevel = "education_level"
ProfileFieldOccupation = "occupation"
ProfileFieldAgeGroup = "age_group"
ProfileFieldLearningGoal = "learning_goal"
ProfileFieldLanguageChallange = "language_challange"
ProfileFieldLanguageGoal = "language_goal"
ProfileFieldFavouriteTopic = "favourite_topic"
ProfileFieldCountry = "country"
ProfileFieldEthiopiaRegions = "ethiopia_regions"
)
// User profile columns validated against field_options on PUT /user (when non-empty).
var UserProfileFieldsWithOptions = []string{
ProfileFieldEducationLevel,
ProfileFieldOccupation,
ProfileFieldAgeGroup,
ProfileFieldLearningGoal,
ProfileFieldLanguageChallange,
ProfileFieldLanguageGoal,
ProfileFieldFavouriteTopic,
}
type ProfileFieldOption struct {
ID int64
FieldKey string
Code string
Label string
DisplayOrder int32
Status string
CreatedAt time.Time
UpdatedAt *time.Time
}
type CreateProfileFieldOptionInput struct {
FieldKey string
Code string
Label string
DisplayOrder *int32
Status *string
}
type UpdateProfileFieldOptionInput struct {
Label *string
DisplayOrder *int32
Status *string
}
type ProfileFieldOptionsGrouped map[string][]ProfileFieldOptionItem
type ProfileFieldOptionItem struct {
Code string `json:"code"`
Label string `json:"label"`
}