Documentation ¶
Index ¶
- Constants
- func CleanTagValue(tagValue string) string
- func ConvertMD5(md5sum [16]byte) []byte
- func Migrations(cfg *config.Giffy) *migration.Suite
- func NewImagePredicate(predicate ImagePredicate) func(item interface{}) bool
- func Schema(cfg *config.Giffy) *migration.Suite
- type ContentRating
- type DayCount
- type DayCounts
- type Error
- type Image
- type ImagePredicate
- type ImageStats
- type Manager
- func (m Manager) CreatTestVoteSummaryWithVote(ctx context.Context, imageID, tagID, userID int64, votesFor, votesAgainst int) (*VoteSummary, error)
- func (m Manager) CreateObject(ctx context.Context, state ...interface{}) error
- func (m Manager) CreateOrUpdateVote(ctx context.Context, userID, imageID, tagID int64, isUpvote bool) (bool, error)
- func (m Manager) CreateTestImage(ctx context.Context, userID int64) (*Image, error)
- func (m Manager) CreateTestSearchHistory(ctx context.Context, source, searchQuery string, imageID, tagID *int64) (*SearchHistory, error)
- func (m Manager) CreateTestTag(ctx context.Context, userID int64, tagValue string) (*Tag, error)
- func (m Manager) CreateTestTagForImageWithVote(ctx context.Context, userID, imageID int64, tagValue string) (*Tag, error)
- func (m Manager) CreateTestUser(ctx context.Context) (*User, error)
- func (m Manager) CreateTestUserAuth(ctx context.Context, userID int64, token, secret string, key []byte) (*UserAuth, error)
- func (m Manager) CreateTestUserSession(ctx context.Context, userID int64) (*UserSession, error)
- func (m Manager) DeleteImageByID(ctx context.Context, imageID int64) error
- func (m Manager) DeleteOrphanedTags(ctx context.Context) error
- func (m Manager) DeleteTagAndVotesByID(ctx context.Context, tagID int64) error
- func (m Manager) DeleteTagByID(ctx context.Context, tagID int64) error
- func (m Manager) DeleteUserAuthForProvider(ctx context.Context, userID int64, provider string) error
- func (m Manager) DeleteUserSession(ctx context.Context, userID int64, sessionID string) error
- func (m Manager) DeleteVote(ctx context.Context, userID, imageID, tagID int64) error
- func (m Manager) DeleteVoteSummary(ctx context.Context, imageID, tagID int64) error
- func (m Manager) GetAllErrorsSince(ctx context.Context, since time.Time) ([]Error, error)
- func (m Manager) GetAllErrorsWithLimitAndOffset(ctx context.Context, limit, offset int) ([]Error, error)
- func (m Manager) GetAllImages(ctx context.Context) ([]Image, error)
- func (m Manager) GetAllImagesWithContentRating(ctx context.Context, contentRating int) ([]Image, error)
- func (m Manager) GetAllSlackTeams(ctx context.Context) ([]SlackTeam, error)
- func (m Manager) GetAllTags(ctx context.Context) ([]Tag, error)
- func (m Manager) GetAllUsers(ctx context.Context) (all []User, err error)
- func (m Manager) GetContentRatingByName(ctx context.Context, name string) (*ContentRating, error)
- func (m Manager) GetImageByID(ctx context.Context, id int64) (*Image, error)
- func (m Manager) GetImageByMD5(ctx context.Context, md5sum []byte) (*Image, error)
- func (m Manager) GetImageByUUID(ctx context.Context, uuid string) (*Image, error)
- func (m Manager) GetImageStats(ctx context.Context, imageID int64) (*ImageStats, error)
- func (m Manager) GetImagesByID(ctx context.Context, ids []int64) ([]Image, error)
- func (m Manager) GetImagesForTagID(ctx context.Context, tagID int64) ([]Image, error)
- func (m Manager) GetImagesForUserID(ctx context.Context, userID int64) ([]Image, error)
- func (m Manager) GetModerationForUserID(ctx context.Context, userID int64) ([]Moderation, error)
- func (m Manager) GetModerationLogByCountAndOffset(ctx context.Context, count, offset int) ([]Moderation, error)
- func (m Manager) GetModerationsByTime(ctx context.Context, after time.Time) ([]Moderation, error)
- func (m Manager) GetRandomImages(ctx context.Context, count int) ([]Image, error)
- func (m Manager) GetRandomTags(ctx context.Context, count int) ([]Tag, error)
- func (m Manager) GetSearchHistory(ctx context.Context) ([]SearchHistory, error)
- func (m Manager) GetSearchHistoryByCountAndOffset(ctx context.Context, count, offset int) ([]SearchHistory, error)
- func (m Manager) GetSearchesPerDay(ctx context.Context, since time.Time) ([]DayCount, error)
- func (m Manager) GetSiteStats(ctx context.Context) (*SiteStats, error)
- func (m Manager) GetSlackTeamByTeamID(ctx context.Context, teamID string) (*SlackTeam, error)
- func (m Manager) GetTagByID(ctx context.Context, id int64) (*Tag, error)
- func (m Manager) GetTagByUUID(ctx context.Context, uuid string) (*Tag, error)
- func (m Manager) GetTagByValue(ctx context.Context, tagValue string) (*Tag, error)
- func (m Manager) GetTagsForImageID(ctx context.Context, imageID int64) ([]Tag, error)
- func (m Manager) GetTopSearchedImages(ctx context.Context, limit int) ([]ImageStats, error)
- func (m Manager) GetUserAuthByProvider(ctx context.Context, userID int64, provider string) (*UserAuth, error)
- func (m Manager) GetUserAuthByToken(ctx context.Context, token string, key []byte) (*UserAuth, error)
- func (m Manager) GetUserByID(ctx context.Context, id int64) (*User, error)
- func (m Manager) GetUserByUUID(ctx context.Context, uuid string) (*User, error)
- func (m Manager) GetUserByUsername(ctx context.Context, username string) (*User, error)
- func (m Manager) GetUsersByCountAndOffset(ctx context.Context, count, offset int) ([]User, error)
- func (m Manager) GetVote(ctx context.Context, userID, imageID, tagID int64) (*Vote, error)
- func (m Manager) GetVoteSummariesForImage(ctx context.Context, imageID int64) ([]VoteSummary, error)
- func (m Manager) GetVoteSummariesForTag(ctx context.Context, tagID int64) ([]VoteSummary, error)
- func (m Manager) GetVoteSummary(ctx context.Context, imageID, tagID int64) (*VoteSummary, error)
- func (m Manager) GetVotesForImage(ctx context.Context, imageID int64) (votes []Vote, err error)
- func (m Manager) GetVotesForTag(ctx context.Context, tagID int64) (votes []Vote, err error)
- func (m Manager) GetVotesForUser(ctx context.Context, userID int64) (votes []Vote, err error)
- func (m Manager) GetVotesForUserForImage(ctx context.Context, userID, imageID int64) ([]Vote, error)
- func (m Manager) GetVotesForUserForTag(ctx context.Context, userID, tagID int64) ([]Vote, error)
- func (m Manager) MergeTags(ctx context.Context, fromTagID, toTagID int64) error
- func (m Manager) ReconcileVoteSummaryTotals(ctx context.Context, imageID, tagID int64) error
- func (m Manager) SearchImages(ctx context.Context, query string, contentRatingFilter int) ([]Image, error)
- func (m Manager) SearchImagesBestResult(ctx context.Context, query string, excludeUUIDs []string, contentRating int) (*Image, error)
- func (m Manager) SearchImagesWeightedRandom(ctx context.Context, query string, contentRatingFilter, count int) ([]Image, error)
- func (m Manager) SearchTags(ctx context.Context, query string) ([]Tag, error)
- func (m Manager) SearchTagsRandom(ctx context.Context, query string, count int) ([]Tag, error)
- func (m Manager) SearchUsers(ctx context.Context, query string) ([]User, error)
- func (m Manager) SetTagValue(ctx context.Context, tagID int64, tagValue string) error
- func (m Manager) SetVoteSummaryTagID(ctx context.Context, imageID, oldTagID, newTagID int64) error
- func (m Manager) SetVoteSummaryVoteCounts(ctx context.Context, imageID, tagID int64, votesFor, votesAgainst int) error
- func (m Manager) SetVoteTagID(ctx context.Context, userID, imageID, oldTagID, newTagID int64) error
- func (m Manager) UpdateImageDisplayName(ctx context.Context, imageID int64, displayName string) error
- type Moderation
- type SearchHistory
- type SiteStats
- type SlackTeam
- type StatAtTime
- type Tag
- type User
- type UserAuth
- type UserSession
- type Vote
- type VoteSummary
Constants ¶
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 )
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 )
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 ¶
CleanTagValue cleans a prospective tag value.
func ConvertMD5 ¶
ConvertMD5 takes a fixed buffer and turns it into a byte slice.
func Migrations ¶
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
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.
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.
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 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 ¶
GetTagsSummary returns a csv of the tags for the image.
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
CreateTestUserSession creates a test user session.
func (Manager) DeleteImageByID ¶
DeleteImageByID deletes an image fully.
func (Manager) DeleteOrphanedTags ¶
DeleteOrphanedTags deletes tags that have no vote_summary link to an image.
func (Manager) DeleteTagAndVotesByID ¶
DeleteTagAndVotesByID deletes an tag fully.
func (Manager) DeleteTagByID ¶
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 ¶
DeleteUserSession removes a session from the db.
func (Manager) DeleteVote ¶
DeleteVote deletes a vote.
func (Manager) DeleteVoteSummary ¶
DeleteVoteSummary deletes an association between an image and a tag.
func (Manager) GetAllErrorsSince ¶
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 ¶
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 ¶
GetAllSlackTeams gets all slack teams.
func (Manager) GetAllTags ¶
GetAllTags returns all the tags in the db.
func (Manager) GetAllUsers ¶
GetAllUsers returns all the users.
func (Manager) GetContentRatingByName ¶
GetContentRatingByName gets a content rating by name.
func (Manager) GetImageByID ¶
GetImageByID returns an image for an id.
func (Manager) GetImageByMD5 ¶
GetImageByMD5 returns an image by uuid.
func (Manager) GetImageByUUID ¶
GetImageByUUID returns an image by uuid.
func (Manager) GetImageStats ¶
GetImageStats gets image stats.
func (Manager) GetImagesByID ¶
GetImagesByID returns images with tags for a list of ids.
func (Manager) GetImagesForTagID ¶
GetImagesForTagID gets all the images attached to a tag.
func (Manager) GetImagesForUserID ¶
GetImagesForUserID returns images for a user.
func (Manager) GetModerationForUserID ¶
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 ¶
GetModerationsByTime returns all moderation entries after a specific time.
func (Manager) GetRandomImages ¶
GetRandomImages returns an image by uuid.
func (Manager) GetRandomTags ¶
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 ¶
GetSearchesPerDay retrieves the number of searches per day.
func (Manager) GetSiteStats ¶
GetSiteStats returns the stats for the site.
func (Manager) GetSlackTeamByTeamID ¶
GetSlackTeamByTeamID gets a slack team by the team id.
func (Manager) GetTagByID ¶
GetTagByID returns a tag for a id.
func (Manager) GetTagByUUID ¶
GetTagByUUID returns a tag for a uuid.
func (Manager) GetTagByValue ¶
GetTagByValue returns a tag for a uuid.
func (Manager) GetTagsForImageID ¶
GetTagsForImageID returns all the tags for an image.
func (Manager) GetTopSearchedImages ¶
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 ¶
GetUserByID returns a user by id.
func (Manager) GetUserByUUID ¶
GetUserByUUID returns a user for a uuid.
func (Manager) GetUserByUsername ¶
GetUserByUsername returns a user for a uuid.
func (Manager) GetUsersByCountAndOffset ¶
GetUsersByCountAndOffset returns users by count and offset.
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 ¶
GetVoteSummariesForTag grabs all vote counts for an image (i.e. for all the tags).
func (Manager) GetVoteSummary ¶
GetVoteSummary fetches an VoteSummary by constituent pks.
func (Manager) GetVotesForImage ¶
GetVotesForImage gets all the votes log entries for an image.
func (Manager) GetVotesForTag ¶
GetVotesForTag gets all the votes log entries for an image.
func (Manager) GetVotesForUser ¶
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 ¶
GetVotesForUserForTag gets the votes for an image by a user.
func (Manager) ReconcileVoteSummaryTotals ¶
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 ¶
SearchTags searches tags.
func (Manager) SearchTagsRandom ¶
SearchTagsRandom searches tags taking a randomly selected count.
func (Manager) SearchUsers ¶
SearchUsers searches users by searchString.
func (Manager) SetTagValue ¶
SetTagValue sets a tag value
func (Manager) SetVoteSummaryTagID ¶
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 ¶
SetVoteTagID sets the tag_id for a vote object.
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) 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 ¶
NewSlackTeam returns a new SlackTeam.
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 (*Tag) PopulateExtra ¶
PopulateExtra pulls data off a reader and sets fields on the struct.
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.
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 ¶
NewUserAuth returns a new user auth entry, encrypting the authToken and authSecret.
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.
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.