Documentation ¶
Overview ¶
Package products represents the story resource
Index ¶
- Constants
- func AllowedParams() []string
- func AllowedParamsAdmin() []string
- func GetTrendingStory() *query.Query
- func Popular() *query.Query
- func Published() *query.Query
- func Query() *query.Query
- func Where(format string, args ...interface{}) *query.Query
- type Story
- func (s *Story) CanonicalURL() string
- func (s *Story) Code() bool
- func (s *Story) CommentCountDisplay() string
- func (s *Story) CompleteURL() string
- func (s *Story) CountSubscribers() int
- func (s *Story) DestinationURL() string
- func (s *Story) Domain() string
- func (s *Story) Editable() bool
- func (s *Story) FileName() string
- func (s *Story) GetHashTag() []string
- func (s *Story) GodocURL() string
- func (s *Story) NameDisplay() string
- func (s *Story) NegativePoints() int64
- func (s *Story) OwnedBy(uid int64) bool
- func (s *Story) PermaURL() string
- func (s *Story) PrimaryURL() string
- func (s *Story) ShowAsk() bool
- func (s *Story) Tags() []string
- func (s *Story) VetURL() string
- func (s *Story) YouTube() bool
- func (s *Story) YouTubeURL() string
Constants ¶
const ( // TableName is the database table for this resource TableName = "products" // KeyName is the primary key value for this resource KeyName = "id" // Order defines the default sort order in sql for this resource Order = "name asc, id desc" // SubscriberColumnName holds the column name of the subscribers SubscriberColumnName = "subscribers" )
Variables ¶
This section is empty.
Functions ¶
func AllowedParams ¶
func AllowedParams() []string
AllowedParams returns the cols editable by everyone
func AllowedParamsAdmin ¶
func AllowedParamsAdmin() []string
AllowedParamsAdmin returns the cols editable by admins
func GetTrendingStory ¶
getTrendingStory returns a story with most number of views in past 30 days except meta stories
Types ¶
type Story ¶
type Story struct { // resource.Base defines behaviour and fields shared between all resources resource.Base // status.ResourceStatus defines a status field and associated behaviour status.ResourceStatus Name string Summary string Description string FeaturedImage string URL string S3Bucket string S3Key string UserID int64 Points int64 Rank int64 CommentCount int64 // UserName denormalises the user name - pull from users join UserName string // Insights AllTimePageViews int64 AllTimeTop3Countries string SevenDaysPageViews int64 SevenDaysTop3Countries string ThirtyDaysPageViews int64 ThirtyDaysTop3Countries string InsightsUpdatedTime time.Time // Subscription Flair string Subscribers []int64 Price map[string]string // Mailchimp MailchimpAudienceID string //Square SquarePrice map[string]map[string]interface{} Schedule string SquareSubscriptionPlanId map[string]string }
Story handles saving and retreiving products from the database
func FindFirst ¶
FindFirst fetches a single story record from the database using a where query with the format and args provided.
func NewWithColumns ¶
NewWithColumns creates a new story instance and fills it with data from the database cols provided.
func (*Story) CanonicalURL ¶
CanonicalURL is the canonical URL of the story on this site including a slug for seo
func (*Story) Code ¶
Code returns true if this is a link to a git repository At present we only check for github urls, we should at least check for bitbucket
func (*Story) CommentCountDisplay ¶
CommentCountDisplay returns the comment count or ellipsis if count is 0
func (*Story) CompleteURL ¶
CompleteURL returns combination of protocol, root url and destination url
func (*Story) CountSubscribers ¶
func (*Story) DestinationURL ¶
DestinationURL returns the URL of the story if no url is set, it uses the CanonicalURL
func (*Story) Editable ¶
Editable returns true if this story is editable. products are editable if less than 1 hours old
func (*Story) GetHashTag ¶
GetHashTag gives the hashtags in the name
func (*Story) NameDisplay ¶
NameDisplay returns a title string without hashtags (assumed to be at the end), by truncating the title at the first #
func (*Story) NegativePoints ¶
NegativePoints returns a negative point score or 0 if points is above 0
func (*Story) PrimaryURL ¶
PrimaryURL returns the URL to use for this story in lists Videos and Show Ask products link to the story for other links for now it is the destination
func (*Story) Tags ¶
Tags are defined as words beginning with # in the title TODO: for speed and clarity we could extract at submit time instead and store in db