dao

package
v1.2.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DB reference to database
	DB *gorm.DB

	Migrator = newMigrator()
)
View Source
var Progress = NewProgressDao()

Functions

func NewCoursesDao added in v1.0.5

func NewCoursesDao() coursesDao

Types

type AllTokensDto

type AllTokensDto struct {
	model.Token
	UserName  string
	UserMail  string
	UserLrzID string
}

type AuditDao added in v1.0.8

type AuditDao interface {
	// Create a new audit for the database
	Create(*model.Audit) error
	// Find audits
	Find(limit int, offset int, types ...model.AuditType) (audits []model.Audit, err error)
}

func NewAuditDao added in v1.0.8

func NewAuditDao() AuditDao

type BookmarkDao added in v1.1.1

type BookmarkDao interface {
	Add(*model.Bookmark) error
	GetByID(uint) (model.Bookmark, error)
	GetByStreamID(uint, uint) ([]model.Bookmark, error)
	Update(*model.Bookmark) error
	Delete(uint) error
}

func NewBookmarkDao added in v1.1.1

func NewBookmarkDao() BookmarkDao

type CalendarResult

type CalendarResult struct {
	StreamID        uint
	Created         time.Time
	Start           time.Time
	End             time.Time
	CourseName      string
	LectureHallName string
}

func (CalendarResult) IsoCreated

func (r CalendarResult) IsoCreated() string

func (CalendarResult) IsoEnd

func (r CalendarResult) IsoEnd() string

func (CalendarResult) IsoStart

func (r CalendarResult) IsoStart() string

type CameraPresetDao added in v1.0.5

type CameraPresetDao interface {
	GetDefaultCameraPreset(lectureHallID uint) (res model.CameraPreset, err error)
}

func NewCameraPresetDao added in v1.0.5

func NewCameraPresetDao() CameraPresetDao

type ChatDao added in v1.0.5

type ChatDao interface {
	AddChatPollOptionVote(pollOptionId uint, userId uint) error
	AddChatPoll(poll *model.Poll) error
	AddMessage(chat *model.Chat) error

	GetChatUsers(streamid uint) ([]model.User, error)
	GetReactions(chatID uint) ([]model.ChatReaction, error)
	GetVisibleChats(userID uint, streamID uint) ([]model.Chat, error)
	GetAllChats(userID uint, streamID uint) ([]model.Chat, error)
	GetActivePoll(streamID uint) (model.Poll, error)
	GetPollUserVote(pollId uint, userId uint) (uint, error)
	GetPollOptionVoteCount(pollOptionId uint) (int64, error)
	GetPolls(streamID uint) ([]model.Poll, error)

	ApproveChat(id uint) error
	RetractChat(id uint) error
	DeleteChat(id uint) error
	ResolveChat(id uint) error
	ToggleReaction(userID uint, chatID uint, username string, emoji string) error
	RemoveReactions(chatID uint) error

	CloseActivePoll(streamID uint) error

	GetChatsByUser(userID uint) ([]model.Chat, error)
	GetChat(id uint, userID uint) (*model.Chat, error)
}

func NewChatDao added in v1.0.5

func NewChatDao() ChatDao

type CoursesDao added in v1.0.5

type CoursesDao interface {
	CreateCourse(ctx context.Context, course *model.Course, keep bool) error
	AddAdminToCourse(userID uint, courseID uint) error

	GetCurrentOrNextLectureForCourse(ctx context.Context, courseID uint) (model.Stream, error)
	GetAllCourses() ([]model.Course, error)
	GetCourseForLecturerIdByYearAndTerm(c context.Context, year int, term string, userId uint) ([]model.Course, error)
	GetAdministeredCoursesByUserId(ctx context.Context, userid uint) (courses []model.Course, err error)
	GetAllCoursesForSemester(year int, term string, ctx context.Context) (courses []model.Course)
	GetPublicCourses(year int, term string) (courses []model.Course, err error)
	GetPublicAndLoggedInCourses(year int, term string) (courses []model.Course, err error)
	GetCourseByToken(token string) (course model.Course, err error)
	GetCourseById(ctx context.Context, id uint) (course model.Course, err error)
	GetInvitedUsersForCourse(course *model.Course) error
	GetCourseBySlugYearAndTerm(ctx context.Context, slug string, term string, year int) (model.Course, error)
	// GetAllCoursesWithTUMIDFromSemester returns all courses with a non-null tum_identifier from a given semester or later
	GetAllCoursesWithTUMIDFromSemester(ctx context.Context, year int, term string) (courses []model.Course, err error)
	GetAvailableSemesters(c context.Context) []Semester
	GetCourseByShortLink(link string) (model.Course, error)
	GetCourseAdmins(courseID uint) ([]model.User, error)

	UpdateCourse(ctx context.Context, course model.Course) error
	UpdateCourseMetadata(ctx context.Context, course model.Course)
	UnDeleteCourse(ctx context.Context, course model.Course) error

	RemoveAdminFromCourse(userID uint, courseID uint) error
	DeleteCourse(course model.Course)
}

type DaoWrapper added in v1.0.5

type DaoWrapper struct {
	CameraPresetDao
	ChatDao
	FileDao
	StreamsDao
	CoursesDao
	WorkerDao
	LectureHallsDao
	UsersDao
	UploadKeyDao
	StatisticsDao
	ProgressDao
	ServerNotificationDao
	TokenDao
	NotificationsDao
	IngestServerDao
	VideoSectionDao
	VideoSeekDao
	KeywordDao
	SearchDao
	// AuditDao.Find(...) seems like a nice api, find can be used in other dao as well if type is not embedded
	AuditDao AuditDao
	InfoPageDao
	BookmarkDao BookmarkDao
	SubtitlesDao
}

func NewDaoWrapper added in v1.0.5

func NewDaoWrapper() DaoWrapper

type FileDao added in v1.0.5

type FileDao interface {
	NewFile(f *model.File) error
	GetFileById(id string) (f model.File, err error)
	UpdateFile(id string, f *model.File) error
	DeleteFile(id uint) error
	CountVoDFiles() (int64, error)
	SetThumbnail(streamId uint, thumb model.File) error
}

func NewFileDao added in v1.0.5

func NewFileDao() FileDao

type InfoPageDao added in v1.0.6

type InfoPageDao interface {
	New(*model.InfoPage) error
	GetAll() ([]model.InfoPage, error)
	GetById(uint) (model.InfoPage, error)
	Update(uint, *model.InfoPage) error
}

func NewInfoPageDao added in v1.0.6

func NewInfoPageDao() InfoPageDao

type IngestServerDao added in v1.0.5

type IngestServerDao interface {
	SaveSlot(slot model.StreamName)
	SaveIngestServer(server model.IngestServer)

	GetBestIngestServer() (server model.IngestServer, err error)
	GetTranscodedStreamSlot(ingestServerID uint) (sn model.StreamName, err error)
	GetStreamSlot(ingestServerID uint) (sn model.StreamName, err error)

	RemoveStreamFromSlot(streamID uint) error
}

func NewIngestServerDao added in v1.0.5

func NewIngestServerDao() IngestServerDao

type KeywordDao added in v1.1.0

type KeywordDao interface {
	NewKeywords(keyword []model.Keyword) error
}

func NewKeywordDao added in v1.1.0

func NewKeywordDao() KeywordDao

type LectureHallsDao added in v1.0.5

type LectureHallsDao interface {
	CreateLectureHall(lectureHall model.LectureHall)
	SavePreset(preset model.CameraPreset) error
	SaveLectureHallFullAssoc(lectureHall model.LectureHall)
	SaveLectureHall(lectureHall model.LectureHall) error

	FindPreset(lectureHallID string, presetID string) (model.CameraPreset, error)
	GetAllLectureHalls() []model.LectureHall
	GetLectureHallByPartialName(name string) (model.LectureHall, error)
	GetLectureHallByID(id uint) (model.LectureHall, error)
	GetStreamsForLectureHallIcal(userId uint, lectureHalls []uint) ([]CalendarResult, error)

	UnsetDefaults(lectureHallID string) error

	DeleteLectureHall(id uint) error
}

func NewLectureHallsDao added in v1.0.5

func NewLectureHallsDao() LectureHallsDao

type NotificationsDao added in v1.0.5

type NotificationsDao interface {
	AddNotification(notification *model.Notification) error

	GetNotifications(target ...model.NotificationTarget) ([]model.Notification, error)
	GetAllNotifications() ([]model.Notification, error)

	DeleteNotification(id uint) error
}

func NewNotificiationsDao added in v1.0.5

func NewNotificiationsDao() NotificationsDao

type ProgressDao added in v1.0.5

type ProgressDao interface {
	SaveProgresses(progresses []model.StreamProgress) error
	GetProgressesForUser(userID uint) ([]model.StreamProgress, error)
	LoadProgress(userID uint, streamID uint) (streamProgress model.StreamProgress, err error)
	SaveWatchedState(progress *model.StreamProgress) error
}

func NewProgressDao added in v1.0.5

func NewProgressDao() ProgressDao

type SearchDao added in v1.0.6

type SearchDao interface {
	Search(q string, courseId uint) ([]model.Stream, error)
}

func NewSearchDao added in v1.0.6

func NewSearchDao() SearchDao

type Semester

type Semester struct {
	TeachingTerm string
	Year         int
}

type ServerNotificationDao added in v1.0.5

type ServerNotificationDao interface {
	CreateServerNotification(notification model.ServerNotification) error

	GetCurrentServerNotifications() ([]model.ServerNotification, error)
	GetAllServerNotifications() ([]model.ServerNotification, error)

	UpdateServerNotification(notification model.ServerNotification, id string) error

	DeleteServerNotification(notificationId string) error
}

func NewServerNotificationDao added in v1.0.5

func NewServerNotificationDao() ServerNotificationDao

type Stat

type Stat struct {
	X string `json:"x"` // label for stat
	Y int    `json:"y"` // value for stat
}

Stat key value struct that is parsable by Chart.js without further modifications. See https://www.chartjs.org/docs/master/general/data-structures.html

type StatisticsDao added in v1.0.5

type StatisticsDao interface {
	AddStat(stat model.Stat) error

	GetCourseNumStudents(courseID uint) (int64, error)
	GetCourseNumVodViews(courseID uint) (int, error)
	GetCourseNumLiveViews(courseID uint) (int, error)
	GetCourseNumVodViewsPerDay(courseID uint) ([]Stat, error)
	GetCourseStatsWeekdays(courseID uint) ([]Stat, error)
	GetCourseStatsHourly(courseID uint) ([]Stat, error)
	GetStudentActivityCourseStats(courseID uint, live bool) ([]Stat, error)
	GetStreamNumLiveViews(streamID uint) (int, error)
}

func NewStatisticsDao added in v1.0.5

func NewStatisticsDao() StatisticsDao

type StreamsDao added in v1.0.5

type StreamsDao interface {
	CreateStream(stream *model.Stream) error
	AddVodView(id string) error

	GetDueStreamsForWorkers() []model.Stream
	GetDuePremieresForWorkers() []model.Stream
	GetStreamByKey(ctx context.Context, key string) (stream model.Stream, err error)
	GetUnitByID(id string) (model.StreamUnit, error)
	GetStreamByTumOnlineID(ctx context.Context, id uint) (stream model.Stream, err error)
	GetStreamsByIds(ids []uint) ([]model.Stream, error)
	GetStreamByID(ctx context.Context, id string) (stream model.Stream, err error)
	GetWorkersForStream(stream model.Stream) ([]model.Worker, error)
	GetAllStreams() ([]model.Stream, error)
	GetCurrentLive(ctx context.Context) (currentLive []model.Stream, err error)
	GetCurrentLiveNonHidden(ctx context.Context) (currentLive []model.Stream, err error)
	GetLiveStreamsInLectureHall(lectureHallId uint) ([]model.Stream, error)
	GetStreamsWithWatchState(courseID uint, userID uint) (streams []model.Stream, err error)

	SetLectureHall(streamIDs []uint, lectureHallID uint) error
	UnsetLectureHall(streamIDs []uint) error
	UpdateStream(stream model.Stream) error
	SaveWorkerForStream(stream model.Stream, worker model.Worker) error
	ClearWorkersForStream(stream model.Stream) error
	UpdateSilences(silences []model.Silence, streamID string) error
	DeleteSilences(streamID string) error
	UpdateStreamFullAssoc(vod *model.Stream) error
	SetStreamNotLiveById(streamID uint) error
	SetStreamLiveNowTimestampById(streamID uint, liveNowTimestamp time.Time) error
	SaveEndedState(streamID uint, hasEnded bool) error
	SaveCOMBURL(stream *model.Stream, url string)
	SaveCAMURL(stream *model.Stream, url string)
	SavePRESURL(stream *model.Stream, url string)
	SaveTranscodingProgress(progress model.TranscodingProgress) error
	RemoveTranscodingProgress(streamVersion model.StreamVersion, streamId uint) error
	GetTranscodingProgressByVersion(streamVersion model.StreamVersion, streamId uint) (model.TranscodingProgress, error)
	SaveStream(vod *model.Stream) error
	ToggleVisibility(streamId uint, private bool) error

	DeleteStream(streamID string)
	DeleteUnit(id uint)
	DeleteStreamsWithTumID(ids []uint)
	UpdateLectureSeries(model.Stream) error
	DeleteLectureSeries(string) error
}

func NewStreamsDao added in v1.0.5

func NewStreamsDao() StreamsDao

type SubtitlesDao added in v1.2.5

type SubtitlesDao interface {
	// Get Subtitles by ID
	Get(context.Context, uint) (model.Subtitles, error)

	// GetByStreamIDandLang returns the subtitles for a given query
	GetByStreamIDandLang(context.Context, uint, string) (model.Subtitles, error)

	// CreateOrUpsert creates or updates subtitles for the database
	CreateOrUpsert(context.Context, *model.Subtitles) error

	// Create saves subtitles
	Create(c context.Context, it *model.Subtitles) error

	// Delete a Subtitles by id.
	Delete(context.Context, uint) error
}

func NewSubtitlesDao added in v1.2.5

func NewSubtitlesDao() SubtitlesDao

type TokenDao added in v1.0.5

type TokenDao interface {
	AddToken(token model.Token) error

	GetToken(token string) (model.Token, error)
	GetAllTokens() ([]AllTokensDto, error)

	TokenUsed(token model.Token) error

	DeleteToken(id string) error
}

func NewTokenDao added in v1.0.5

func NewTokenDao() TokenDao

type UploadKeyDao added in v1.0.3

type UploadKeyDao interface {
	GetUploadKey(key string) (model.UploadKey, error)
	CreateUploadKey(key string, stream uint) error
	DeleteUploadKey(key model.UploadKey) error
}

func NewUploadKeyDao added in v1.0.3

func NewUploadKeyDao() UploadKeyDao

type UsersDao added in v1.0.5

type UsersDao interface {
	AreUsersEmpty(ctx context.Context) (isEmpty bool, err error)
	CreateUser(ctx context.Context, user *model.User) (err error)
	DeleteUser(ctx context.Context, uid uint) (err error)
	SearchUser(query string) (users []model.User, err error)
	IsUserAdmin(ctx context.Context, uid uint) (res bool, err error)
	GetUserByEmail(ctx context.Context, email string) (user model.User, err error)
	GetAllAdminsAndLecturers(users *[]model.User) (err error)
	GetUserByID(ctx context.Context, id uint) (user model.User, err error)
	CreateRegisterLink(ctx context.Context, user model.User) (registerLink model.RegisterLink, err error)
	GetUserByResetKey(key string) (model.User, error)
	DeleteResetKey(key string)
	UpdateUser(user model.User) error
	PinCourse(user model.User, course model.Course, pin bool) error
	UpsertUser(user *model.User) error
	AddUsersToCourseByTUMIDs(matrNr []string, courseID uint) error
	AddUserSetting(userSetting *model.UserSetting) error
}

func NewUsersDao added in v1.0.5

func NewUsersDao() UsersDao

type VideoSectionDao added in v1.0.4

type VideoSectionDao interface {
	Create([]model.VideoSection) error
	Update(*model.VideoSection) error
	Delete(uint) error
	Get(uint) (model.VideoSection, error)
	GetByStreamId(uint) ([]model.VideoSection, error)
}

func NewVideoSectionDao added in v1.0.4

func NewVideoSectionDao() VideoSectionDao

type VideoSeekDao added in v1.1.0

type VideoSeekDao interface {
	Add(streamID string, pos float64) error
	Get(streamID string) ([]model.VideoSeekChunk, error)
}

func NewVideoSeekDao added in v1.1.0

func NewVideoSeekDao() VideoSeekDao

type WorkerDao added in v1.0.5

type WorkerDao interface {
	CreateWorker(worker *model.Worker) error
	SaveWorker(worker model.Worker) error

	GetAllWorkers() ([]model.Worker, error)
	GetAliveWorkers() []model.Worker
	GetWorkerByHostname(ctx context.Context, hostname string) (model.Worker, error)
	GetWorkerByID(ctx context.Context, workerID string) (model.Worker, error)

	DeleteWorker(workerID string) error
}

func NewWorkerDao added in v1.0.5

func NewWorkerDao() WorkerDao

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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