usecase

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: 23 Imported by: 0

Documentation

Index

Constants

View Source
const MaxFollowTeacherCount = 20

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorRecorder

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

func NewErrorRecorder

func NewErrorRecorder(appLogger *zap.Logger, repo repository.ErrorRecorder) *ErrorRecorder

func (*ErrorRecorder) Record

func (er *ErrorRecorder) Record(ctx context.Context, err error, userID string)

type FollowingTeacher

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

func NewFollowingTeacher

func NewFollowingTeacher(
	appLogger *zap.Logger,
	dbRepo repository.DB,
	followingTeacherRepo repository.FollowingTeacher,
	userRepo repository.User,
	teacherRepo repository.Teacher,
	lessonFetcherRepo repository.LessonFetcher,
) *FollowingTeacher

func (*FollowingTeacher) Create

func (u *FollowingTeacher) Create(ctx context.Context, followingTeacher *model2.FollowingTeacher) error

func (*FollowingTeacher) DeleteFollowingTeachers

func (u *FollowingTeacher) DeleteFollowingTeachers(ctx context.Context, userID uint, teacherIDs []uint) error

func (*FollowingTeacher) FindTeachersByUserID

func (u *FollowingTeacher) FindTeachersByUserID(ctx context.Context, userID uint) ([]*model2.Teacher, error)

func (*FollowingTeacher) FollowTeacher

func (u *FollowingTeacher) FollowTeacher(ctx context.Context, user *model2.User, teacher *model2.Teacher) (*model2.FollowingTeacher, bool, error)

func (*FollowingTeacher) ReachesFollowingTeacherLimit

func (u *FollowingTeacher) ReachesFollowingTeacherLimit(ctx context.Context, userID uint, additionalTeachers int) (bool, error)

type GAMeasurement

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

func NewGAMeasurement

func NewGAMeasurement(gaMeasurementRepo repository.GAMeasurement) *GAMeasurement

func (*GAMeasurement) SendEvent

func (u *GAMeasurement) SendEvent(
	ctx context.Context,
	values *model2.GAMeasurementEvent,
	category, action, label string,
	value int64,
	userID uint32,
) error

type Lesson

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

func NewLesson

func NewLesson(
	lessonRepo repository.Lesson,
	lessonStatusLogRepo repository.LessonStatusLog,
) *Lesson

func (*Lesson) FindLessons

func (u *Lesson) FindLessons(
	ctx context.Context,
	teacherID uint, fromDate, toDate time.Time,
) ([]*model2.Lesson, error)

func (*Lesson) GetNewAvailableLessons

func (u *Lesson) GetNewAvailableLessons(ctx context.Context, oldLessons, newLessons []*model2.Lesson) []*model2.Lesson

func (*Lesson) UpdateLessons

func (u *Lesson) UpdateLessons(ctx context.Context, lessons []*model2.Lesson) (int, error)

type LessonNotifier

type LessonNotifier struct{}

func (*LessonNotifier) Close

func (ln *LessonNotifier) Close(ctx context.Context, stat *model2.StatNotifier)

func (*LessonNotifier) SendNotification

func (ln *LessonNotifier) SendNotification(ctx context.Context, user *model2.User) error

type Notification

type Notification struct {
}

func NewNotification

func NewNotification() *Notification

func (*Notification) NewLessonNotifier

func (n *Notification) NewLessonNotifier(lessonFetcher repository.LessonFetcher) *LessonNotifier

type NotificationTimeSpan

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

func NewNotificationTimeSpan

func NewNotificationTimeSpan(notificationTimeSpanRepo repository.NotificationTimeSpan) *NotificationTimeSpan

func (*NotificationTimeSpan) FindByUserID

func (u *NotificationTimeSpan) FindByUserID(ctx context.Context, userID uint) ([]*model2.NotificationTimeSpan, error)

func (*NotificationTimeSpan) UpdateAll

func (u *NotificationTimeSpan) UpdateAll(ctx context.Context, userID uint, timeSpans []*model2.NotificationTimeSpan) error

type Notifier

type Notifier struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewNotifier

func NewNotifier(
	appLogger *zap.Logger,
	db *gorm.DB,
	errorRecorder *ErrorRecorder,
	fetcher repository.LessonFetcher,
	dryRun bool,
	lessonUsecase *Lesson,
	notificationTimeSpanUsecase *NotificationTimeSpan,
	statNotifierUsecase *StatNotifier,
	teacherUsecase *Teacher,
	sender repository.EmailSender,
	followingTeacherRepo repository.FollowingTeacher,
) *Notifier

func (*Notifier) Close

func (n *Notifier) Close(ctx context.Context, stat *model2.StatNotifier)

func (*Notifier) SendNotification

func (n *Notifier) SendNotification(ctx context.Context, user *model2.User) error

type StatNotifier

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

func NewStatNotifier

func NewStatNotifier(statNotifierRepo repository.StatNotifier) *StatNotifier

func (*StatNotifier) CreateOrUpdate

func (u *StatNotifier) CreateOrUpdate(ctx context.Context, statNotifier *model2.StatNotifier) error

type Teacher

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

func NewTeacher

func NewTeacher(teacherRepo repository.Teacher) *Teacher

func (*Teacher) CreateOrUpdate

func (u *Teacher) CreateOrUpdate(ctx context.Context, teacher *model2.Teacher) error

func (*Teacher) IncrementFetchErrorCount

func (u *Teacher) IncrementFetchErrorCount(ctx context.Context, id uint, value int) error

type User

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

func NewUser

func NewUser(dbRepo repository.DB, userRepo repository.User, userGoogleRepo repository.UserGoogle) *User

func (*User) CreateWithGoogle

func (u *User) CreateWithGoogle(ctx context.Context, name, email, googleID string) (*model2.User, *model2.UserGoogle, error)

func (*User) FindAllByEmailVerified

func (u *User) FindAllByEmailVerified(ctx context.Context, notificationInterval int) ([]*model2.User, error)

func (*User) FindByGoogleID

func (u *User) FindByGoogleID(ctx context.Context, googleID string) (*model2.User, error)

func (*User) FindLoggedInUser

func (u *User) FindLoggedInUser(ctx context.Context, apiToken string) (*model2.User, error)

func (*User) IsDuplicateEmail

func (u *User) IsDuplicateEmail(ctx context.Context, email string) (bool, error)

func (*User) IsValidEmail

func (u *User) IsValidEmail(email string) bool

func (*User) UpdateEmail

func (u *User) UpdateEmail(ctx context.Context, id uint, email string) error

type UserAPIToken

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

func NewUserAPIToken

func NewUserAPIToken(userAPITokenRepo repository.UserAPIToken) *UserAPIToken

func (*UserAPIToken) Create

func (u *UserAPIToken) Create(ctx context.Context, userID uint) (*model2.UserAPIToken, error)

func (*UserAPIToken) DeleteByUserIDAndToken

func (u *UserAPIToken) DeleteByUserIDAndToken(ctx context.Context, userID uint, token string) error

Jump to

Keyboard shortcuts

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