model

package
v0.0.0-...-5b4c5eb Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMPlanID = uint8(1)
View Source
const MaxFollowTeacherCount = 20

Variables

View Source
var LessonStatuses = goenum.EnumerateStruct(&LessonStatus{
	Finished:  1,
	Reserved:  2,
	Available: 3,
	Cancelled: 4,
})

Functions

func OpenDB

func OpenDB(dsn string, maxConnections int, logging bool) (*gorm.DB, error)

func Placeholders

func Placeholders(values []interface{}) string

func ReplaceToTestDBURL

func ReplaceToTestDBURL(t *testing.T, dbURL string) string

Types

type EventLogEmail

type EventLogEmail struct {
	Datetime   time.Time
	Event      string
	EmailType  string
	UserID     uint32
	UserAgent  string
	TeacherIDs string
	URL        string
}

func (*EventLogEmail) TableName

func (*EventLogEmail) TableName() string

type EventLogEmailService

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

func NewEventLogEmailService

func NewEventLogEmailService(db *gorm.DB) *EventLogEmailService

func (*EventLogEmailService) Create

func (*EventLogEmailService) FindStatDailyNotificationEventByDate

func (s *EventLogEmailService) FindStatDailyNotificationEventByDate(date time.Time) ([]*StatDailyNotificationEvent, error)

func (*EventLogEmailService) FindStatDailyNotificationEventUUCountByDate

func (s *EventLogEmailService) FindStatDailyNotificationEventUUCountByDate(date time.Time) ([]*StatDailyNotificationEvent, error)

func (*EventLogEmailService) FindStatDailyUserNotificationEvent

func (s *EventLogEmailService) FindStatDailyUserNotificationEvent(date time.Time) ([]*StatDailyUserNotificationEvent, error)

func (*EventLogEmailService) FindStatsNewLessonNotifierByDate

func (s *EventLogEmailService) FindStatsNewLessonNotifierByDate(date time.Time) ([]*StatNewLessonNotifier, error)

func (*EventLogEmailService) FindStatsNewLessonNotifierUUCountByDate

func (s *EventLogEmailService) FindStatsNewLessonNotifierUUCountByDate(date time.Time) ([]*StatNewLessonNotifier, error)

type FollowingTeacher

type FollowingTeacher struct {
	UserID    uint32 `gorm:"primary_key"`
	TeacherID uint32 `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*FollowingTeacher) TableName

func (*FollowingTeacher) TableName() string

type FollowingTeacherService

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

func NewFollowingTeacherService

func NewFollowingTeacherService(db *gorm.DB) *FollowingTeacherService

func (*FollowingTeacherService) FindTeacherIDs

func (s *FollowingTeacherService) FindTeacherIDs() ([]uint32, error)

func (*FollowingTeacherService) TableName

func (s *FollowingTeacherService) TableName() string

type LessonStatus

type LessonStatus struct {
	Finished  int `goenum:"終了"`
	Reserved  int `goenum:"予約済"`
	Available int `goenum:"予約可"`
	Cancelled int `goenum:"休講"`
}

type MCountry

type MCountry struct {
	ID        uint16 `gorm:"primary_key"`
	Name      string
	NameJA    string
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*MCountry) TableName

func (*MCountry) TableName() string

type NotificationTimeSpan

type NotificationTimeSpan struct {
	UserID    uint32
	Number    uint8
	FromTime  string
	ToTime    string
	CreatedAt time.Time
	// contains filtered or unexported fields
}

func (*NotificationTimeSpan) ParseTime

func (s *NotificationTimeSpan) ParseTime() error

func (*NotificationTimeSpan) TableName

func (*NotificationTimeSpan) TableName() string

func (*NotificationTimeSpan) Within

func (s *NotificationTimeSpan) Within(t time.Time) bool

type NotificationTimeSpanList

type NotificationTimeSpanList []*NotificationTimeSpan

func (NotificationTimeSpanList) Within

func (l NotificationTimeSpanList) Within(t time.Time) bool

type NotificationTimeSpanService

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

func NewNotificationTimeSpanService

func NewNotificationTimeSpanService(db *gorm.DB) *NotificationTimeSpanService

func (*NotificationTimeSpanService) FindByUserID

func (s *NotificationTimeSpanService) FindByUserID(
	ctx context.Context,
	userID uint32,
) ([]*NotificationTimeSpan, error)

FindByUserID is used from SendNotification on notifier.go

func (*NotificationTimeSpanService) UpdateAll

func (s *NotificationTimeSpanService) UpdateAll(userID uint32, timeSpans []*NotificationTimeSpan) error

UpdateAll is used from TestNotifier_SendNotification

type StatDailyNotificationEvent

type StatDailyNotificationEvent struct {
	Date    time.Time
	Event   string
	Count   uint32
	UUCount uint32
}

func (*StatDailyNotificationEvent) TableName

func (*StatDailyNotificationEvent) TableName() string

type StatDailyNotificationEventService

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

func NewStatDailyNotificationEventService

func NewStatDailyNotificationEventService(db *gorm.DB) *StatDailyNotificationEventService

func (*StatDailyNotificationEventService) CreateOrUpdate

func (*StatDailyNotificationEventService) FindAllByDate

type StatDailyUserNotificationEvent

type StatDailyUserNotificationEvent struct {
	Date   time.Time
	UserID uint32
	Event  string
	Count  uint32
}

func (*StatDailyUserNotificationEvent) TableName

type StatDailyUserNotificationEventService

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

func NewStatDailyUserNotificationEventService

func NewStatDailyUserNotificationEventService(db *gorm.DB) *StatDailyUserNotificationEventService

func (*StatDailyUserNotificationEventService) CreateOrUpdate

func (s *StatDailyUserNotificationEventService) CreateOrUpdate(date time.Time) error

func (*StatDailyUserNotificationEventService) FindAllByDate

type StatNewLessonNotifier

type StatNewLessonNotifier struct {
	Date    time.Time
	Event   string
	Count   uint32
	UUCount uint32
}

func (*StatNewLessonNotifier) TableName

func (*StatNewLessonNotifier) TableName() string

type StatNewLessonNotifierService

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

func NewStatsNewLessonNotifierService

func NewStatsNewLessonNotifierService(db *gorm.DB) *StatNewLessonNotifierService

func (*StatNewLessonNotifierService) CreateOrUpdate

type StatNotifier

type StatNotifier struct {
	Datetime             time.Time
	Interval             uint8
	Elapsed              uint32
	UserCount            uint32
	FollowedTeacherCount uint32
}

func (*StatNotifier) TableName

func (*StatNotifier) TableName() string

type StatNotifierService

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

func NewStatNotifierService

func NewStatNotifierService(db *gorm.DB) *StatNotifierService

func (*StatNotifierService) CreateOrUpdate

func (s *StatNotifierService) CreateOrUpdate(v *StatNotifier) error

type Teacher

type Teacher struct {
	ID                uint32
	Name              string
	CountryID         uint16
	Gender            string
	Birthday          time.Time
	YearsOfExperience uint8
	FavoriteCount     uint32
	ReviewCount       uint32
	Rating            float32
	LastLessonAt      time.Time
	FetchErrorCount   uint8
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

func NewTeacher

func NewTeacher(id uint32) *Teacher

func NewTeachersFromIDsOrURL

func NewTeachersFromIDsOrURL(idsOrURL string) ([]*Teacher, error)

func (*Teacher) IsJapanese

func (t *Teacher) IsJapanese() bool

func (*Teacher) TableName

func (*Teacher) TableName() string

func (*Teacher) URL

func (t *Teacher) URL() string

type TeacherService

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

func NewTeacherService

func NewTeacherService(db *gorm.DB) *TeacherService

func (*TeacherService) CreateOrUpdate

func (s *TeacherService) CreateOrUpdate(t *Teacher) error

func (*TeacherService) FindByFetchErrorCountGt

func (s *TeacherService) FindByFetchErrorCountGt(count uint32) ([]*Teacher, error)

func (*TeacherService) FindByPK

func (s *TeacherService) FindByPK(id uint32) (*Teacher, error)

func (*TeacherService) IncrementFetchErrorCount

func (s *TeacherService) IncrementFetchErrorCount(id uint32, value int) error

func (*TeacherService) ResetFetchErrorCount

func (s *TeacherService) ResetFetchErrorCount(id uint32) error

type TestHelper

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

func NewTestHelper

func NewTestHelper() *TestHelper

func (*TestHelper) CreateRandomTeacher

func (h *TestHelper) CreateRandomTeacher(t *testing.T) *Teacher

func (*TestHelper) CreateRandomUser

func (h *TestHelper) CreateRandomUser(t *testing.T) *User

func (*TestHelper) CreateTeacher

func (h *TestHelper) CreateTeacher(t *testing.T, id uint32, name string) *Teacher

func (*TestHelper) CreateUser

func (h *TestHelper) CreateUser(t *testing.T, name, email string) *User

func (*TestHelper) DB

func (h *TestHelper) DB(t *testing.T) *gorm.DB

func (*TestHelper) GetDBName

func (h *TestHelper) GetDBName(dbURL string) string

func (*TestHelper) LoadAllTables

func (h *TestHelper) LoadAllTables(t *testing.T, db *gorm.DB) []string

func (*TestHelper) TruncateAllTables

func (h *TestHelper) TruncateAllTables(t *testing.T)

type User

type User struct {
	ID                 uint32 `gorm:"primary_key;AUTO_INCREMENT"`
	Name               string
	Email              string
	EmailVerified      bool
	PlanID             uint8
	FollowedTeacherAt  sql.NullTime
	OpenNotificationAt sql.NullTime
	CreatedAt          time.Time
	UpdatedAt          time.Time
}

func (*User) IsFollowedTeacher

func (u *User) IsFollowedTeacher() bool

func (*User) TableName

func (*User) TableName() string

type UserService

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

func NewUserService

func NewUserService(db *gorm.DB) *UserService

func (*UserService) Create

func (s *UserService) Create(name, email string) (*User, error)

func (*UserService) FindAllFollowedTeacherAtIsNull

func (s *UserService) FindAllFollowedTeacherAtIsNull(createdAt time.Time) ([]*User, error)

FindAllFollowedTeacherAtIsNull returns an empty slice if no users found

func (*UserService) FindByPK

func (s *UserService) FindByPK(id uint32) (*User, error)

func (*UserService) FindLoggedInUser

func (s *UserService) FindLoggedInUser(token string) (*User, error)

func (*UserService) TableName

func (s *UserService) TableName() string

func (*UserService) UpdateOpenNotificationAt

func (s *UserService) UpdateOpenNotificationAt(userID uint32, t time.Time) error

Jump to

Keyboard shortcuts

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