model

package
v0.0.0-...-785145d Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContentRatingG = 1
	ContentRatingG = 1

	// ContentRatingPG = 2
	ContentRatingPG = 2

	// ContentRatingPG13 = 3
	ContentRatingPG13 = 3

	// ContentRatingR = 4
	ContentRatingR = 4

	// ContentRatingNR = 5
	ContentRatingNR = 5

	// ContentRatingFilterDefault < ContentRatingNR
	ContentRatingFilterDefault = ContentRatingNR

	// ContentRatingFilterAll will returns all images (including NR).
	ContentRatingFilterAll = 6
)
View Source
const (
	// MaxImageSize is 32 megabytes.
	MaxImageSize = 1 << 25 // 32 mb

	// MinImageHeight is the min height
	MinImageHeight = 200

	// MinImageWidth is the min image width
	MinImageWidth = 200

	// MinImageHeightOrWidth is the minimum height or width.
	MinImageHeightOrWidth = 300
)
View Source
const (
	// ModerationVerbCreate = "create"
	ModerationVerbCreate = "create"
	// ModerationVerbUpdate = "update"
	ModerationVerbUpdate = "update"
	// ModerationVerbDelete = "delete"
	ModerationVerbDelete = "delete"
	// ModerationVerbConsolidate = "consolidate"
	ModerationVerbConsolidate = "consolidate"
	// ModerationVerbPromoteAsModerator = "promote_moderator"
	ModerationVerbPromoteAsModerator = "promote_moderator"
	// ModerationVerbDemoteAsModerator = "demote_moderator"
	ModerationVerbDemoteAsModerator = "demote_moderator"
	// ModerationVerbBan = "ban"
	ModerationVerbBan = "ban"
	// ModerationVerbUnban = "unban"
	ModerationVerbUnban = "unban"
	// ModerationObjectImage = "image"
	ModerationObjectImage = "image"
	// ModerationObjectTag = "tag"
	ModerationObjectTag = "tag"
	// ModerationObjectLink = "link"
	ModerationObjectLink = "link"
	// ModerationObjectUser = "user"
	ModerationObjectUser = "user"
)

Variables

This section is empty.

Functions

func CleanTagValue

func CleanTagValue(tagValue string) string

CleanTagValue cleans a prospective tag value.

func ConvertMD5

func ConvertMD5(md5sum [16]byte) []byte

ConvertMD5 takes a fixed buffer and turns it into a byte slice.

func Migrations

func Migrations(cfg *config.Giffy) *migration.Suite

Migrations returns the migrations.

func NewImagePredicate

func NewImagePredicate(predicate ImagePredicate) func(item interface{}) bool

NewImagePredicate creates a new ImagePredicate that resolves to a linq.Predicate

func Schema

func Schema(cfg *config.Giffy) *migration.Suite

Schema returns the initialize migrations.

Types

type ContentRating

type ContentRating struct {
	ID          int    `json:"id" db:"id,pk"`
	Name        string `json:"name" db:"name"`
	Description string `json:"description" db:"description"`
}

ContentRating is a rating for content similar to the MPAA ratings for movies.

func NewContentRating

func NewContentRating() *ContentRating

NewContentRating returns a new ContentRating instance.

func (*ContentRating) IsZero

func (cr *ContentRating) IsZero() bool

IsZero returns if the object is empty or not.

func (*ContentRating) Populate

func (cr *ContentRating) Populate(rows *sql.Rows) error

Populate skips spiffy reflection lookups for populting rows.

func (*ContentRating) TableName

func (cr *ContentRating) TableName() string

TableName returns the table name.

type DayCount

type DayCount struct {
	Year  int     `db:"year,readonly"`
	Month int     `db:"month,readonly"`
	Day   int     `db:"day,readonly"`
	Count float64 `db:"count,readonly"`
}

DayCount represents a count per day.

func (*DayCount) ChartData

func (dc *DayCount) ChartData() (time.Time, float64)

ChartData returns the dayCount as a usable value.

func (*DayCount) Populate

func (dc *DayCount) Populate(row *sql.Rows) error

Populate manually populates the object.

type DayCounts

type DayCounts []DayCount

DayCounts is an array of DayCount.

func (DayCounts) ChartData

func (dcs DayCounts) ChartData() ([]time.Time, []float64)

ChartData returns the day count list as a chart data item.

type Error

type Error struct {
	UUID       string    `json:"uuid" db:"uuid,pk"`
	CreatedUTC time.Time `json:"created_utc" db:"created_utc"`
	Message    string    `json:"message" db:"message"`
	StackTrace string    `json:"stack_trace" db:"stack_trace"`

	Verb  string `json:"verb" db:"verb"`
	Proto string `json:"proto" db:"proto"`
	Host  string `json:"host" db:"host"`
	Path  string `json:"path" db:"path"`
	Query string `json:"query" db:"query"`
}

Error represents an exception that has bubbled up to the global exception handler.

func NewError

func NewError(err error, req *http.Request) *Error

NewError creates a new error.

func (Error) TableName

func (e Error) TableName() string

TableName returns the mapped table name.

type Image

type Image struct {
	ID            int64     `json:"-" db:"id,pk,serial"`
	UUID          string    `json:"uuid" db:"uuid"`
	CreatedUTC    time.Time `json:"created_utc" db:"created_utc"`
	CreatedBy     int64     `json:"-" db:"created_by"`
	CreatedByUser *User     `json:"created_by,omitempty" db:"-"`

	DisplayName   string `json:"display_name" db:"display_name"`
	ContentRating int    `json:"content_rating" db:"content_rating"`

	MD5      []byte `json:"md5" db:"md5"`
	S3Bucket string `json:"s3_bucket" db:"s3_bucket"`
	S3Key    string `json:"s3_key" db:"s3_key"`

	Width  int `json:"width" db:"width"`
	Height int `json:"height" db:"height"`

	FileSize  int    `json:"file_size" db:"file_size"`
	Extension string `json:"extension" db:"extension"`

	Tags []Tag `json:"tags,omitempty" db:"-"`
}

Image is an image stored in the db.

func NewImage

func NewImage() *Image

NewImage returns a new instance of an image.

func NewImageFromPostedFile

func NewImageFromPostedFile(userID int64, shouldValidate bool, fileContents []byte, fileName string) (*Image, error)

NewImageFromPostedFile creates an image and parses the meta data for an image from a posted file.

func (Image) GetTagsSummary

func (i Image) GetTagsSummary() string

GetTagsSummary returns a csv of the tags for the image.

func (Image) IsZero

func (i Image) IsZero() bool

IsZero returns if the object has been set.

func (*Image) Populate

func (i *Image) Populate(r db.Rows) error

Populate popultes the object from rows.

func (Image) TableName

func (i Image) TableName() string

TableName returns the tablename for the object.

type ImagePredicate

type ImagePredicate func(i Image) bool

ImagePredicate is used in linq queries

type ImageStats

type ImageStats struct {
	ImageID    int64 `json:"image_id" db:"image_id,readonly"`
	Image      *Image
	VotesTotal int `json:"votes_total" db:"votes_total,readonly"`
	Searches   int `json:"searches" db:"searches,readonly"`
}

ImageStats contains some basic stats for a given image.

func (ImageStats) TableName

func (is ImageStats) TableName() string

TableName returns the table name.

type Manager

type Manager struct {
	dbutil.BaseManager
}

Manager is the common entrypoint for model functions.

func NewTestManager

func NewTestManager(tx *sql.Tx) Manager

NewTestManager returns a new manager specifically for testing.

func (Manager) CreatTestVoteSummaryWithVote

func (m Manager) CreatTestVoteSummaryWithVote(ctx context.Context, imageID, tagID, userID int64, votesFor, votesAgainst int) (*VoteSummary, error)

CreatTestVoteSummaryWithVote creates a test vote summary with an accopanying vote.

func (Manager) CreateObject

func (m Manager) CreateObject(ctx context.Context, state ...interface{}) error

CreateObject creates an object (for use with the work queue)

func (Manager) CreateOrUpdateVote

func (m Manager) CreateOrUpdateVote(ctx context.Context, userID, imageID, tagID int64, isUpvote bool) (bool, error)

CreateOrUpdateVote votes for a tag for an image in the db.

func (Manager) CreateTestImage

func (m Manager) CreateTestImage(ctx context.Context, userID int64) (*Image, error)

CreateTestImage creates a test image.

func (Manager) CreateTestSearchHistory

func (m Manager) CreateTestSearchHistory(ctx context.Context, source, searchQuery string, imageID, tagID *int64) (*SearchHistory, error)

CreateTestSearchHistory creates a test search history entry.

func (Manager) CreateTestTag

func (m Manager) CreateTestTag(ctx context.Context, userID int64, tagValue string) (*Tag, error)

CreateTestTag creates a test tag.

func (Manager) CreateTestTagForImageWithVote

func (m Manager) CreateTestTagForImageWithVote(ctx context.Context, userID, imageID int64, tagValue string) (*Tag, error)

CreateTestTagForImageWithVote creates a test tag for an image and seeds the vote summary for it.

func (Manager) CreateTestUser

func (m Manager) CreateTestUser(ctx context.Context) (*User, error)

CreateTestUser creates a test user.

func (Manager) CreateTestUserAuth

func (m Manager) CreateTestUserAuth(ctx context.Context, userID int64, token, secret string, key []byte) (*UserAuth, error)

CreateTestUserAuth creates a test user auth.

func (Manager) CreateTestUserSession

func (m Manager) CreateTestUserSession(ctx context.Context, userID int64) (*UserSession, error)

CreateTestUserSession creates a test user session.

func (Manager) DeleteImageByID

func (m Manager) DeleteImageByID(ctx context.Context, imageID int64) error

DeleteImageByID deletes an image fully.

func (Manager) DeleteOrphanedTags

func (m Manager) DeleteOrphanedTags(ctx context.Context) error

DeleteOrphanedTags deletes tags that have no vote_summary link to an image.

func (Manager) DeleteTagAndVotesByID

func (m Manager) DeleteTagAndVotesByID(ctx context.Context, tagID int64) error

DeleteTagAndVotesByID deletes an tag fully.

func (Manager) DeleteTagByID

func (m Manager) DeleteTagByID(ctx context.Context, tagID int64) error

DeleteTagByID deletes a tag.

func (Manager) DeleteUserAuthForProvider

func (m Manager) DeleteUserAuthForProvider(ctx context.Context, userID int64, provider string) error

DeleteUserAuthForProvider deletes auth entries for a provider for a user.

func (Manager) DeleteUserSession

func (m Manager) DeleteUserSession(ctx context.Context, userID int64, sessionID string) error

DeleteUserSession removes a session from the db.

func (Manager) DeleteVote

func (m Manager) DeleteVote(ctx context.Context, userID, imageID, tagID int64) error

DeleteVote deletes a vote.

func (Manager) DeleteVoteSummary

func (m Manager) DeleteVoteSummary(ctx context.Context, imageID, tagID int64) error

DeleteVoteSummary deletes an association between an image and a tag.

func (Manager) GetAllErrorsSince

func (m Manager) GetAllErrorsSince(ctx context.Context, since time.Time) ([]Error, error)

GetAllErrorsSince gets all the errors since a cutoff.

func (Manager) GetAllErrorsWithLimitAndOffset

func (m Manager) GetAllErrorsWithLimitAndOffset(ctx context.Context, limit, offset int) ([]Error, error)

GetAllErrorsWithLimitAndOffset gets all the errors up to a limit.

func (Manager) GetAllImages

func (m Manager) GetAllImages(ctx context.Context) ([]Image, error)

GetAllImages returns all the images in the database.

func (Manager) GetAllImagesWithContentRating

func (m Manager) GetAllImagesWithContentRating(ctx context.Context, contentRating int) ([]Image, error)

GetAllImagesWithContentRating gets all censored images

func (Manager) GetAllSlackTeams

func (m Manager) GetAllSlackTeams(ctx context.Context) ([]SlackTeam, error)

GetAllSlackTeams gets all slack teams.

func (Manager) GetAllTags

func (m Manager) GetAllTags(ctx context.Context) ([]Tag, error)

GetAllTags returns all the tags in the db.

func (Manager) GetAllUsers

func (m Manager) GetAllUsers(ctx context.Context) (all []User, err error)

GetAllUsers returns all the users.

func (Manager) GetContentRatingByName

func (m Manager) GetContentRatingByName(ctx context.Context, name string) (*ContentRating, error)

GetContentRatingByName gets a content rating by name.

func (Manager) GetImageByID

func (m Manager) GetImageByID(ctx context.Context, id int64) (*Image, error)

GetImageByID returns an image for an id.

func (Manager) GetImageByMD5

func (m Manager) GetImageByMD5(ctx context.Context, md5sum []byte) (*Image, error)

GetImageByMD5 returns an image by uuid.

func (Manager) GetImageByUUID

func (m Manager) GetImageByUUID(ctx context.Context, uuid string) (*Image, error)

GetImageByUUID returns an image by uuid.

func (Manager) GetImageStats

func (m Manager) GetImageStats(ctx context.Context, imageID int64) (*ImageStats, error)

GetImageStats gets image stats.

func (Manager) GetImagesByID

func (m Manager) GetImagesByID(ctx context.Context, ids []int64) ([]Image, error)

GetImagesByID returns images with tags for a list of ids.

func (Manager) GetImagesForTagID

func (m Manager) GetImagesForTagID(ctx context.Context, tagID int64) ([]Image, error)

GetImagesForTagID gets all the images attached to a tag.

func (Manager) GetImagesForUserID

func (m Manager) GetImagesForUserID(ctx context.Context, userID int64) ([]Image, error)

GetImagesForUserID returns images for a user.

func (Manager) GetModerationForUserID

func (m Manager) GetModerationForUserID(ctx context.Context, userID int64) ([]Moderation, error)

GetModerationForUserID gets all the moderation entries for a user.

func (Manager) GetModerationLogByCountAndOffset

func (m Manager) GetModerationLogByCountAndOffset(ctx context.Context, count, offset int) ([]Moderation, error)

GetModerationLogByCountAndOffset returns all moderation entries after a specific time.

func (Manager) GetModerationsByTime

func (m Manager) GetModerationsByTime(ctx context.Context, after time.Time) ([]Moderation, error)

GetModerationsByTime returns all moderation entries after a specific time.

func (Manager) GetRandomImages

func (m Manager) GetRandomImages(ctx context.Context, count int) ([]Image, error)

GetRandomImages returns an image by uuid.

func (Manager) GetRandomTags

func (m Manager) GetRandomTags(ctx context.Context, count int) ([]Tag, error)

GetRandomTags gets a random selection of tags.

func (Manager) GetSearchHistory

func (m Manager) GetSearchHistory(ctx context.Context) ([]SearchHistory, error)

GetSearchHistory returns the entire search history in chrono order.

func (Manager) GetSearchHistoryByCountAndOffset

func (m Manager) GetSearchHistoryByCountAndOffset(ctx context.Context, count, offset int) ([]SearchHistory, error)

GetSearchHistoryByCountAndOffset returns the search history in chrono order by count and offset.

func (Manager) GetSearchesPerDay

func (m Manager) GetSearchesPerDay(ctx context.Context, since time.Time) ([]DayCount, error)

GetSearchesPerDay retrieves the number of searches per day.

func (Manager) GetSiteStats

func (m Manager) GetSiteStats(ctx context.Context) (*SiteStats, error)

GetSiteStats returns the stats for the site.

func (Manager) GetSlackTeamByTeamID

func (m Manager) GetSlackTeamByTeamID(ctx context.Context, teamID string) (*SlackTeam, error)

GetSlackTeamByTeamID gets a slack team by the team id.

func (Manager) GetTagByID

func (m Manager) GetTagByID(ctx context.Context, id int64) (*Tag, error)

GetTagByID returns a tag for a id.

func (Manager) GetTagByUUID

func (m Manager) GetTagByUUID(ctx context.Context, uuid string) (*Tag, error)

GetTagByUUID returns a tag for a uuid.

func (Manager) GetTagByValue

func (m Manager) GetTagByValue(ctx context.Context, tagValue string) (*Tag, error)

GetTagByValue returns a tag for a uuid.

func (Manager) GetTagsForImageID

func (m Manager) GetTagsForImageID(ctx context.Context, imageID int64) ([]Tag, error)

GetTagsForImageID returns all the tags for an image.

func (Manager) GetTopSearchedImages

func (m Manager) GetTopSearchedImages(ctx context.Context, limit int) ([]ImageStats, error)

GetTopSearchedImages gets all the stats for images.

func (Manager) GetUserAuthByProvider

func (m Manager) GetUserAuthByProvider(ctx context.Context, userID int64, provider string) (*UserAuth, error)

GetUserAuthByProvider returns an auth entry for the given auth token.

func (Manager) GetUserAuthByToken

func (m Manager) GetUserAuthByToken(ctx context.Context, token string, key []byte) (*UserAuth, error)

GetUserAuthByToken returns an auth entry for the given auth token.

func (Manager) GetUserByID

func (m Manager) GetUserByID(ctx context.Context, id int64) (*User, error)

GetUserByID returns a user by id.

func (Manager) GetUserByUUID

func (m Manager) GetUserByUUID(ctx context.Context, uuid string) (*User, error)

GetUserByUUID returns a user for a uuid.

func (Manager) GetUserByUsername

func (m Manager) GetUserByUsername(ctx context.Context, username string) (*User, error)

GetUserByUsername returns a user for a uuid.

func (Manager) GetUsersByCountAndOffset

func (m Manager) GetUsersByCountAndOffset(ctx context.Context, count, offset int) ([]User, error)

GetUsersByCountAndOffset returns users by count and offset.

func (Manager) GetVote

func (m Manager) GetVote(ctx context.Context, userID, imageID, tagID int64) (*Vote, error)

GetVote gets a user's vote for an image and a tag.

func (Manager) GetVoteSummariesForImage

func (m Manager) GetVoteSummariesForImage(ctx context.Context, imageID int64) ([]VoteSummary, error)

GetVoteSummariesForImage grabs all vote counts for an image (i.e. for all the tags).

func (Manager) GetVoteSummariesForTag

func (m Manager) GetVoteSummariesForTag(ctx context.Context, tagID int64) ([]VoteSummary, error)

GetVoteSummariesForTag grabs all vote counts for an image (i.e. for all the tags).

func (Manager) GetVoteSummary

func (m Manager) GetVoteSummary(ctx context.Context, imageID, tagID int64) (*VoteSummary, error)

GetVoteSummary fetches an VoteSummary by constituent pks.

func (Manager) GetVotesForImage

func (m Manager) GetVotesForImage(ctx context.Context, imageID int64) (votes []Vote, err error)

GetVotesForImage gets all the votes log entries for an image.

func (Manager) GetVotesForTag

func (m Manager) GetVotesForTag(ctx context.Context, tagID int64) (votes []Vote, err error)

GetVotesForTag gets all the votes log entries for an image.

func (Manager) GetVotesForUser

func (m Manager) GetVotesForUser(ctx context.Context, userID int64) (votes []Vote, err error)

GetVotesForUser gets all the vote log entries for a user.

func (Manager) GetVotesForUserForImage

func (m Manager) GetVotesForUserForImage(ctx context.Context, userID, imageID int64) ([]Vote, error)

GetVotesForUserForImage gets the votes for an image by a user.

func (Manager) GetVotesForUserForTag

func (m Manager) GetVotesForUserForTag(ctx context.Context, userID, tagID int64) ([]Vote, error)

GetVotesForUserForTag gets the votes for an image by a user.

func (Manager) MergeTags

func (m Manager) MergeTags(ctx context.Context, fromTagID, toTagID int64) error

MergeTags merges the fromTagID into the toTagID, deleting the fromTagID.

func (Manager) ReconcileVoteSummaryTotals

func (m Manager) ReconcileVoteSummaryTotals(ctx context.Context, imageID, tagID int64) error

ReconcileVoteSummaryTotals queries the `vote` table to fill the vote count aggregate columns on `vote_summary`.

func (Manager) SearchImages

func (m Manager) SearchImages(ctx context.Context, query string, contentRatingFilter int) ([]Image, error)

SearchImages searches for an image.

func (Manager) SearchImagesBestResult

func (m Manager) SearchImagesBestResult(ctx context.Context, query string, excludeUUIDs []string, contentRating int) (*Image, error)

SearchImagesBestResult pulls the best result for a query. This method is used for slack searches.

func (Manager) SearchImagesWeightedRandom

func (m Manager) SearchImagesWeightedRandom(ctx context.Context, query string, contentRatingFilter, count int) ([]Image, error)

SearchImagesWeightedRandom pulls a random count of images based on a search query. The most common `count` is 1.

func (Manager) SearchTags

func (m Manager) SearchTags(ctx context.Context, query string) ([]Tag, error)

SearchTags searches tags.

func (Manager) SearchTagsRandom

func (m Manager) SearchTagsRandom(ctx context.Context, query string, count int) ([]Tag, error)

SearchTagsRandom searches tags taking a randomly selected count.

func (Manager) SearchUsers

func (m Manager) SearchUsers(ctx context.Context, query string) ([]User, error)

SearchUsers searches users by searchString.

func (Manager) SetTagValue

func (m Manager) SetTagValue(ctx context.Context, tagID int64, tagValue string) error

SetTagValue sets a tag value

func (Manager) SetVoteSummaryTagID

func (m Manager) SetVoteSummaryTagID(ctx context.Context, imageID, oldTagID, newTagID int64) error

SetVoteSummaryTagID re-assigns a vote summary's tag.

func (Manager) SetVoteSummaryVoteCounts

func (m Manager) SetVoteSummaryVoteCounts(ctx context.Context, imageID, tagID int64, votesFor, votesAgainst int) error

SetVoteSummaryVoteCounts updates the votes for a tag to an image.

func (Manager) SetVoteTagID

func (m Manager) SetVoteTagID(ctx context.Context, userID, imageID, oldTagID, newTagID int64) error

SetVoteTagID sets the tag_id for a vote object.

func (Manager) UpdateImageDisplayName

func (m Manager) UpdateImageDisplayName(ctx context.Context, imageID int64, displayName string) error

UpdateImageDisplayName sets just the display name for an image.

type Moderation

type Moderation struct {
	UserID        int64     `json:"user_id" db:"user_id"`
	UUID          string    `json:"uuid" db:"uuid,pk"`
	TimestampUTC  time.Time `json:"timestamp_utc" db:"timestamp_utc"`
	Verb          string    `json:"verb" db:"verb"`
	Object        string    `json:"object" db:"object"`
	Noun          string    `json:"noun" db:"noun"`
	SecondaryNoun string    `json:"secondary_noun" db:"secondary_noun"`

	Moderator *User `json:"moderator" db:"-"`

	User  *User  `json:"user,omitempty" db:"-"`
	Image *Image `json:"image,omitempty" db:"-"`
	Tag   *Tag   `json:"tag,omitempty" db:"-"`
}

Moderation is the moderation log.

func NewModeration

func NewModeration(userID int64, verb, object string, nouns ...string) *Moderation

NewModeration returns a new moderation object

func (Moderation) GetFlag

func (m Moderation) GetFlag() string

Flag implements logger.event.

func (Moderation) IsZero

func (m Moderation) IsZero() bool

IsZero returns if the object is set.

func (Moderation) TableName

func (m Moderation) TableName() string

TableName returns the table

func (Moderation) WriteText

func (m Moderation) WriteText(tf logger.TextFormatter, output io.Writer)

WriteText implements logger.TextWritable.

type SearchHistory

type SearchHistory struct {
	Source string `json:"source" db:"source"`

	SourceTeamIdentifier    string `json:"source_team_identifier" db:"source_team_identifier"`
	SourceTeamName          string `json:"source_team_name" db:"source_team_name"`
	SourceChannelIdentifier string `json:"source_channel_identifier" db:"source_channel_identifier"`
	SourceChannelName       string `json:"source_channel_name" db:"source_channel_name"`
	SourceUserIdentifier    string `json:"source_user_identifier" db:"source_user_identifier"`
	SourceUserName          string `json:"source_user_name" db:"source_user_name"`

	TimestampUTC time.Time `json:"timestamp_utc" db:"timestamp_utc"`
	SearchQuery  string    `json:"search_query" db:"search_query"`

	DidFindMatch bool `json:"did_find_match" db:"did_find_match"`

	ImageID *int64 `json:"image_id" db:"image_id"`
	Image   *Image `json:"image" db:"-"`
	TagID   *int64 `json:"tag_id" db:"tag_id"`
	Tag     *Tag   `json:"tag" db:"-"`
}

SearchHistory is a record of searches and the primary result.

func NewSearchHistory

func NewSearchHistory(source, searchQuery string, didFindMatch bool, imageID, tagID *int64) *SearchHistory

NewSearchHistory returns a new search history.

func NewSearchHistoryDetailed

func NewSearchHistoryDetailed(source, sourceTeamID, sourceTeamName, sourceChannelID, sourceChannelName, sourceUserID, sourceUserName, searchQuery string, didFindMatch bool, imageID, tagID *int64) *SearchHistory

NewSearchHistoryDetailed queues logging a new moderation log entry.

func (SearchHistory) GetFlag

func (sh SearchHistory) GetFlag() string

Flag implements logger.Event.

func (SearchHistory) TableName

func (sh SearchHistory) TableName() string

TableName returns the table name

func (SearchHistory) WriteText

func (sh SearchHistory) WriteText(tf logger.TextFormatter, output io.Writer)

WriteText implements logger.TextWritable.

type SiteStats

type SiteStats struct {
	UserCount        int `json:"user_count"`
	ImageCount       int `json:"image_count"`
	TagCount         int `json:"tag_count"`
	KarmaTotal       int `json:"karma_total"`
	OrphanedTagCount int `json:"orphaned_tag_count"`
}

SiteStats is the current counts for various things on the site.

type SlackTeam

type SlackTeam struct {
	TeamID              string    `json:"team_id" db:"team_id,pk"`
	TeamName            string    `json:"team_name" db:"team_name"`
	CreatedUTC          time.Time `json:"created_utc" db:"created_utc"`
	IsEnabled           bool      `json:"is_enabled" db:"is_enabled"`
	CreatedByID         string    `json:"created_by_id" db:"created_by_id"`
	CreatedByName       string    `json:"created_by_name" db:"created_by_name"`
	ContentRatingFilter int       `json:"content_rating" db:"content_rating"`
}

SlackTeam is a team that is mapped to giffy.

func NewSlackTeam

func NewSlackTeam(teamID, teamName, userID, userName string) *SlackTeam

NewSlackTeam returns a new SlackTeam.

func (SlackTeam) IsZero

func (st SlackTeam) IsZero() bool

IsZero returns if the object has been set or not.

func (SlackTeam) TableName

func (st SlackTeam) TableName() string

TableName returns the mapped table name.

type StatAtTime

type StatAtTime struct {
	TimestampUTC time.Time `json:"timestamp_utc"`
	Value        float64   `json:"value"`
	Label        string    `json:"label"`
}

StatAtTime is a stat value at a time.

type Tag

type Tag struct {
	ID         int64     `json:"-" db:"id,pk,serial"`
	UUID       string    `json:"uuid" db:"uuid"`
	CreatedUTC time.Time `json:"created_utc" db:"created_utc"`
	CreatedBy  int64     `json:"-" db:"created_by"`
	TagValue   string    `json:"tag_value" db:"tag_value"`

	CreatedByUUID string `json:"created_by,omitempty" db:"created_by_uuid,readonly"`
	ImageID       int64  `json:"-" db:"image_uuid,readonly"`
	VotesFor      int    `json:"votes_for,omitempty" db:"votes_for,readonly"`
	VotesAgainst  int    `json:"votes_against,omitempty" db:"votes_against,readonly"`
	VotesTotal    int    `json:"votes_total" db:"votes_total,readonly"`
	VoteRank      int    `json:"vote_rank,omitempty" db:"vote_rank,readonly"`
}

Tag is a label for an image or set of images.

func NewTag

func NewTag(createdBy int64, tagValue string) *Tag

NewTag returns a new tag.

func (*Tag) IsZero

func (t *Tag) IsZero() bool

IsZero denotes if an object has been set or not.

func (*Tag) Populate

func (t *Tag) Populate(r db.Rows) error

Populate pulls data off a reader and sets fields on the struct.

func (*Tag) PopulateExtra

func (t *Tag) PopulateExtra(r db.Rows) error

PopulateExtra pulls data off a reader and sets fields on the struct.

func (Tag) TableName

func (t Tag) TableName() string

TableName returns the name of a table.

type User

type User struct {
	ID         int64     `json:"id" db:"id,pk,serial"`
	UUID       string    `json:"uuid" db:"uuid"`
	CreatedUTC time.Time `json:"created_utc" db:"created_utc"`
	Username   string    `json:"username" db:"username"`
	FirstName  string    `json:"first_name" db:"first_name"`
	LastName   string    `json:"last_name" db:"last_name"`

	EmailAddress    string `json:"email_address" db:"email_address"`
	IsEmailVerified bool   `json:"is_email_verified" db:"is_email_verified"`

	IsAdmin     bool `json:"is_admin" db:"is_admin"`
	IsModerator bool `json:"is_moderator" db:"is_moderator"`
	IsBanned    bool `json:"is_banned" db:"is_banned"`
}

User is a user in the app.

func NewUser

func NewUser(username string) *User

NewUser returns a new user.

func (User) IsZero

func (u User) IsZero() bool

IsZero returns if the user is set or not.

func (*User) Populate

func (u *User) Populate(r db.Rows) error

Populate scans the rows into the struct.

func (User) TableName

func (u User) TableName() string

TableName is the table name.

type UserAuth

type UserAuth struct {
	UserID        int64     `json:"user_id" db:"user_id,pk"`
	TimestampUTC  time.Time `json:"timestamp_utc" db:"timestamp_utc"`
	Provider      string    `json:"provider" db:"provider,pk"`
	AuthToken     []byte    `json:"auth_token" db:"auth_token"`
	AuthTokenHash []byte    `json:"auth_token_hash" db:"auth_token_hash"`
	AuthSecret    []byte    `json:"auth_secret" db:"auth_secret"`
}

UserAuth is what we use to store auth credentials.

func NewUserAuth

func NewUserAuth(userID int64, authToken, authSecret string, key []byte) (*UserAuth, error)

NewUserAuth returns a new user auth entry, encrypting the authToken and authSecret.

func (UserAuth) IsZero

func (ua UserAuth) IsZero() bool

IsZero returns if the object has been set or not.

func (UserAuth) TableName

func (ua UserAuth) TableName() string

TableName returns the table name.

type UserSession

type UserSession struct {
	UserID       int64     `json:"user_id" db:"user_id"`
	TimestampUTC time.Time `json:"timestamp_utc" db:"timestamp_utc"`
	SessionID    string    `json:"session_id" db:"session_id,pk"`
}

UserSession is a session for a user

func NewUserSession

func NewUserSession(userID int64) *UserSession

NewUserSession returns a new user session.

func (UserSession) IsZero

func (us UserSession) IsZero() bool

IsZero returns if a session is zero or not.

func (UserSession) TableName

func (us UserSession) TableName() string

TableName returns the table name.

type Vote

type Vote struct {
	UserID     int64     `json:"-" db:"user_id,pk"`
	UserUUID   string    `json:"user_uuid" db:"user_uuid,readonly"`
	ImageID    int64     `json:"-" db:"image_id,pk"`
	ImageUUID  string    `json:"image_uuid" db:"image_uuid,readonly"`
	TagID      int64     `json:"-" db:"tag_id,pk"`
	TagUUID    string    `json:"tag_uuid" db:"tag_uuid,readonly"`
	CreatedUTC time.Time `json:"created_utc" db:"created_utc"`
	IsUpvote   bool      `json:"is_upvote" db:"is_upvote"`
}

Vote is a vote by a user for an image and tag.

func NewVote

func NewVote(userID, imageID, tagID int64, isUpvote bool) *Vote

NewVote returns a new vote log entry.

func (Vote) IsZero

func (v Vote) IsZero() bool

IsZero returns if the object is set or not.

func (*Vote) Populate

func (v *Vote) Populate(r *sql.Rows) error

Populate skips spiffy struct parsing.

func (Vote) TableName

func (v Vote) TableName() string

TableName returns the name of the table.

type VoteSummary

type VoteSummary struct {
	ImageID        int64     `json:"image_id" db:"image_id,pk"`
	ImageUUID      string    `json:"image_uuid" db:"image_uuid,readonly"`
	TagID          int64     `json:"tag_id" db:"tag_id,pk"`
	TagUUID        string    `json:"tag_uuid" db:"tag_uuid,readonly"`
	CreatedUTC     time.Time `json:"created_utc" db:"created_utc"`
	LastVoteUTC    time.Time `json:"last_vote_utc" db:"last_vote_utc"`
	LastVoteBy     int64     `json:"last_vote_by" db:"last_vote_by"`
	LastVoteByUUID string    `json:"last_vote_by_uuid" db:"last_vote_by_uuid,readonly"`
	VotesFor       int       `json:"votes_for" db:"votes_for"`
	VotesAgainst   int       `json:"votes_against" db:"votes_against"`
	VotesTotal     int       `json:"votes_total" db:"votes_total"`
}

VoteSummary is the link between an image and a tag.

func NewVoteSummary

func NewVoteSummary(imageID, tagID, lastVoteBy int64, lastVoteUTC time.Time) *VoteSummary

NewVoteSummary returns a new instance for an ImageTagVotes.

func (VoteSummary) IsZero

func (itv VoteSummary) IsZero() bool

IsZero returns if an image has been set.

func (VoteSummary) TableName

func (itv VoteSummary) TableName() string

TableName returns the tablename for an object.

Jump to

Keyboard shortcuts

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