models

package
v0.0.0-...-56103b5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAnnouncement

func AddAnnouncement(a *Announcement) (err error)

AddAnnouncement inserts a new announcement into the database

func AddComment

func AddComment(c *Comment) (err error)

AddComment adds a new Comment to the database.

func AddModeration

func AddModeration(a *Moderation) (err error)

AddModeration inserts a new moderations into the database

func AddTicket

func AddTicket(t *Ticket) (err error)

AddTicket inserts a new ticket into the database

func DelAnnouncement

func DelAnnouncement(id int64) (err error)

DelAnnouncement deletes a announcement based on the AnnouncementID

func DelTicket

func DelTicket(id int64) (err error)

DelTicket deletes a ticket based on the TicketID

func DeleteComment

func DeleteComment(id int64) (err error)

DeleteComment deletes a comment from the database.

func HasTicketWithCategory

func HasTicketWithCategory(c string) bool

func SetupEngine

func SetupEngine() *xorm.Engine

SetupEngine sets up an XORM engine according to the database configuration and syncs the schema.

func UpdateAnnouncement

func UpdateAnnouncement(a *Announcement) (err error)

UpdateAnnouncement updates an announcement in the database.

func UpdateAnnouncementCols

func UpdateAnnouncementCols(a *Announcement, cols ...string) error

UpdateAnnouncementCols updates an announcement in the database including the specified columns, even if the fields are empty.

func UpdateComment

func UpdateComment(c *Comment) (err error)

UpdateComment updates a comment in the database.

func UpdateTicket

func UpdateTicket(t *Ticket) (err error)

UpdateTicket updates a comment in the database.

func UpdateTicketCols

func UpdateTicketCols(t *Ticket, cols ...string) error

UpdateTicketCols updates a ticket in the database including the specified columns, even if the fields are empty.

Types

type Announcement

type Announcement struct {
	AnnouncementID int64  `xorm:"pk autoincr"`
	Summary        string `xorm:"-"`
	Title          string `xorm:"text"`
	Tags           string `xorm:"text"`
	CreatedUnix    int64  `xorm:"created"`
	UpdatedUnix    int64  `xorm:"updated"`
	Description    string `xorm:"text"`
}

Announcement represents an announcement

func GetAnnouncement

func GetAnnouncement(id int64) (*Announcement, error)

GetAnnouncement fetches an announcement based on the AnnouncementID

func GetAnnouncements

func GetAnnouncements() (announcements []Announcement)

GetAnnouncements fetches all announcement in the database

type Comment

type Comment struct {
	CommentID     int64  `xorm:"pk autoincr"`
	TicketID      int64  `xorm:"notnull"`
	PosterID      string `xorm:"notnull"`
	IsAdmin       bool
	Text          string        `xorm:"notnull"`
	FormattedText template.HTML `xorm:"-" json:"-"`
	CreatedUnix   int64         `xorm:"created"`
	UpdatedUnix   int64         `xorm:"updated"`
}

Comment represents an anonymous comment to a ticket.

func GetComment

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

GetComment gets a comment based on the ID. It will return the pointer to the Comment, and whether there was an error.

type HotTickets

type HotTickets []Ticket

HotTicket implements sort.Interface for []Ticket based on iota score diminished by time.

func (HotTickets) Len

func (p HotTickets) Len() int

func (HotTickets) Less

func (p HotTickets) Less(i, j int) bool

func (HotTickets) Swap

func (p HotTickets) Swap(i, j int)

type Moderation

type Moderation struct {
	ModerationID         int64 `xorm:"pk autoincr"`
	CreatedUnix          int64 `xorm:"created"`
	UpdatedUnix          int64 `xorm:"updated"`
	Admin                string
	Title                string `xorm:"text"`
	Description          string `xorm:"text"`
	DescriptionSensitive bool
	Reason               string `xorm:"text"`
}

Moderation represents an moderations

func GetModeration

func GetModeration(id int64) (*Moderation, error)

GetModeration fetches an announcement based on the ModerationID

func GetModerations

func GetModerations() (moderations []Moderation)

GetModerations fetches all moderations in the database

type ModerationSort

type ModerationSort []Moderation

ModerationSort implements sort.Interface for []Moderation depending on date.

func (ModerationSort) Len

func (p ModerationSort) Len() int

func (ModerationSort) Less

func (p ModerationSort) Less(i, j int) bool

func (ModerationSort) Swap

func (p ModerationSort) Swap(i, j int)

type Ticket

type Ticket struct {
	TicketID      int64  `xorm:"pk autoincr"`
	Title         string `xorm:"text"`
	Category      string `xorm:"text"`
	CreatedUnix   int64  `xorm:"created"`
	UpdatedUnix   int64  `xorm:"updated"`
	Description   string `xorm:"text"`
	Voters        []string
	IsRep         bool `xorm:"bool"` // Used for adding badge to emphasise rep tickets
	IsResolved    bool
	CommentsCount int       `xorm:"-"`
	Comments      []Comment `xorm:"-"`
}

Ticket represents an issue

func GetCategory

func GetCategory(category string) (tickets []Ticket)

GetCategory creates a new array of type Ticket and populates it with tickets of a certain category

func GetTicket

func GetTicket(id int64) (*Ticket, error)

GetTicket fetches a ticket based on the TicketID

func GetTickets

func GetTickets() (tickets []Ticket)

GetTickets fetches all tickets in the database

func (*Ticket) LoadComments

func (t *Ticket) LoadComments() (err error)

LoadComments loads the comments of the ticket into a non-mapped field.

Jump to

Keyboard shortcuts

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