events

package
v0.0.0-...-0953be8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckUser

func CheckUser() gin.HandlerFunc

CheckUser checks whether a user is attached to the current context

func Count

func Count() int

Count returns the total number of events

func CountBookmarks

func CountBookmarks() int

CountBookmarks counts the number of bookmarks

func CountCategories

func CountCategories() int

CountCategories counts the number of categories

func CountComments

func CountComments() int

CountComments returns the total number of comments

func CountFaculties

func CountFaculties() int

CountFaculties counts the number of faculties

func CountReviews

func CountReviews() int

CountReviews the total number of reviews

func Delete

func Delete(key string) error

Delete removes an event by its Id

func DeleteBookmark

func DeleteBookmark(bookmark *Bookmark) error

DeleteBookmark removes a user by its Id

func DeleteComment

func DeleteComment(id string) error

DeleteComment removes a comment by its Id

func DeleteReview

func DeleteReview(key string) error

DeleteReview removes a review by its Id

func FindCountReviews

func FindCountReviews(query *ReviewQuery) int

FindCountReviews returns the amount of reviews matching the given query

func FlushCaches

func FlushCaches()

FlushCaches invalidates all event-related caches

func GetCategories

func GetCategories() ([]string, error)

GetCategories retrieves all categories

func GetCategoriesAtIndex

func GetCategoriesAtIndex(index int) ([]string, error)

GetCategoriesAtIndex ?

func GetCurrentSemester

func GetCurrentSemester() (curr string, err error)

GetCurrentSemester returns the current semester

func GetFaculties

func GetFaculties() ([]string, error)

GetFaculties retrieves all faculties

func GetMaxCommentIndexByEvent

func GetMaxCommentIndexByEvent(eventID string) (count uint8, err error)

GetMaxCommentIndexByEvent returns the index of the last inserted comment for the given event

func GetReviewAverages

func GetReviewAverages(eventID string) (map[string]float32, error)

GetReviewAverages aggregates the average ratings of all reviews of a given event

func GetTypes

func GetTypes() ([]string, error)

GetTypes retrieves all types of events

func Init

func Init(store *bolthold.Store, eventBus *hub.Hub)

Init initializes a new events store

func Insert

func Insert(event *Event, upsert bool, overwrite bool) error

Insert adds a new event or updates an existing one

func InsertBookmark

func InsertBookmark(bookmark *Bookmark) error

InsertBookmark adds a new bookmark or updates an existing one

func InsertComment

func InsertComment(comment *Comment, upsert bool) error

InsertComment adds a new comment or updates an existing one

func InsertMulti

func InsertMulti(events []*Event, upsert bool, overwrite bool) error

InsertMulti adds a new events or updates an existing ones

func InsertReview

func InsertReview(review *Review, upsert bool) error

InsertReview adds a new review or updates an existing one

func MustGetCurrentSemester

func MustGetCurrentSemester() string

MustGetCurrentSemester returns the current semester

func RegisterAPIRoutes

func RegisterAPIRoutes(router *gin.Engine, group *gin.RouterGroup)

RegisterAPIRoutes registers all API routes with the given router instance

func RegisterRoutes

func RegisterRoutes(router *gin.Engine, group *gin.RouterGroup)

RegisterRoutes registers all public routes with the given router instance

func Reindex

func Reindex()

Reindex rebuilds all indices in the events bucket

Types

type Bookmark

type Bookmark struct {
	Id       uint64 `boltholdKey:"Id"`
	UserId   string `boltholdIndex:"UserId"`
	EntityId string `boltholdIndex:"EntityId"`
}

Bookmark represents a bookmarked event

func FindBookmark

func FindBookmark(userID, entityID string) (*Bookmark, error)

FindBookmark retrieves the bookmarks for the given user and event

func FindBookmarks

func FindBookmarks(userID string) ([]*Bookmark, error)

FindBookmarks retrieves a list of bookmarks for the given user

func GetAllBookmarks

func GetAllBookmarks() ([]*Bookmark, error)

GetAllBookmarks retrieves all bookmarks

func GetBookmark

func GetBookmark(key uint64) (*Bookmark, error)

GetBookmark retrieves a bookmark by its Id

type Comment

type Comment struct {
	Id        string    `form:"" boltholdIndex:"Id"`
	Index     uint8     `form:"" boltholdIndex:"Index"`
	EventId   string    `form:"event_id" boltholdIndex:"EventId"`
	UserId    string    `form:"" boltholdIndex:"UserId"`
	Active    bool      `form:"" boltholdIndex:"Active"`
	Text      string    `form:"text" binding:"required"`
	CreatedAt time.Time `form:""`
}

Comment represents a comment for an event

func FindComments

func FindComments(query *CommentQuery) ([]*Comment, error)

FindComments retrieves a list of comments matching the given query

func GetAllComments

func GetAllComments() ([]*Comment, error)

GetAllComments retrieves all available comments

func GetComment

func GetComment(id string) (*Comment, error)

GetComment retrieves a comment by its Id

type CommentQuery

type CommentQuery struct {
	EventIdEq string
	UserIdEq  string
	ActiveEq  bool
	Skip      int
	Limit     int
}

CommentQuery is used to query for comments

type Event

type Event struct {
	Id            string `boltholdIndex:"Id"`
	Gguid         string
	Name          string `boltholdIndex:"Name"`
	Type          string `boltholdIndex:"Type"`
	Description   string
	Faculty       string
	Institute     string   `boltholdIndex:"Institute"`
	Rating        float32  // for caching purposes only; actual rating is kept as reviews.Reviews
	InverseRating float32  `boltholdIndex:"InverseRating"`
	Categories    []string `boltholdSliceIndex:"Categories"`
	Links         []*Link
	Dates         []*EventDate
	Lecturers     []*Lecturer
	Semesters     []string `boltholdSliceIndex:"Semesters"`
}

Event represents an events (lecture, tutorial, etc.) in this application

func Find

func Find(query *EventQuery) ([]*Event, error)

Find retrieves a list of events matching the given query

func Get

func Get(id string) (*Event, error)

Get retrieves an event by its Id

func GetAll

func GetAll() ([]*Event, error)

GetAll returns all events

func (*Event) GetFaculty

func (l *Event) GetFaculty() string

func (*Event) InSummer

func (l *Event) InSummer() bool

InSummer returns whether or not this event takes place in the summer term

func (*Event) InWinter

func (l *Event) InWinter() bool

InWinter returns whether or not this event takes place in the winter term

func (l *Event) Link(baseURL string) string

Link returns the Url to this event

func (Event) String

func (l Event) String() string

type EventDate

type EventDate struct {
	Date string
	Room string
}

EventDate represents date and location of an event

type EventQuery

type EventQuery struct {
	NameLike     string
	TypeEq       string
	LecturerIdEq string
	SemesterEq   string
	CategoryIn   []string
	Skip         int
	Limit        int
	SortFields   []string
}

EventQuery is used to query saved events

type EventSearchResultItem

type EventSearchResultItem struct {
	Id        string   `json:"id"`
	Name      string   `json:"name"`
	Type      string   `json:"type"`
	Lecturers []string `json:"lecturers"`
}

EventSearchResultItem represents an item in the result list of an event query

func NewEventSearchResultItem

func NewEventSearchResultItem(event *Event) *EventSearchResultItem

NewEventSearchResultItem instantiates a new EventSearchResultItem

type Lecturer

type Lecturer struct {
	Gguid string
	Name  string
}

Lecturer represents the lecturer of an event

func GetLecturers

func GetLecturers() ([]*Lecturer, error)

GetLecturers retrieves all lecturers

func (Lecturer) String

func (l Lecturer) String() string
type Link struct {
	Name string
	Url  string
}

Link represents an external link of an event

type Review

type Review struct {
	Id        string           `json:"" boltholdIndex:"Id"`
	EventId   string           `json:"event_id" boltholdIndex:"EventId"`
	UserId    string           `json:"" boltholdIndex:"UserId"`
	Ratings   map[string]uint8 `json:"ratings"`
	CreatedAt time.Time        `json:"" boltholdIndex:"CreatedAt"`
}

Review represents an event review

TODO: View models!

func FindReviews

func FindReviews(query *ReviewQuery) ([]*Review, error)

FindReviews retrieves a list of reviews matching the given query

func GetAllReviews

func GetAllReviews() ([]*Review, error)

GetAllReviews retrieves all reviews

func GetReview

func GetReview(id string) (*Review, error)

GetReview retrieves a review by its Id

type ReviewQuery

type ReviewQuery struct {
	EventIdEq string
	UserIdEq  string
}

ReviewQuery is used to query for reviews

type Semesters

type Semesters []string

Semesters represents a sortable list of semester identifiers

func GetSemesters

func GetSemesters() (Semesters, error)

GetSemesters retrieves all semesters

func (Semesters) Len

func (s Semesters) Len() int

func (Semesters) Less

func (s Semesters) Less(i, j int) bool

func (Semesters) Swap

func (s Semesters) Swap(i, j int)

Jump to

Keyboard shortcuts

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