products

package
v0.0.0-...-a11cca7 Latest Latest
Warning

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

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

Documentation

Overview

Package products represents the story resource

Index

Constants

View Source
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

func GetTrendingStory() *query.Query

getTrendingStory returns a story with most number of views in past 30 days except meta stories

func Popular() *query.Query

Popular returns a query for all products with points over a certain threshold

func Published

func Published() *query.Query

Published returns a query for all products with status >= published.

func Query

func Query() *query.Query

Query returns a new query for products with a default order.

func Where

func Where(format string, args ...interface{}) *query.Query

Where returns a new query for products with the format and arguments supplied.

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 Find

func Find(id int64) (*Story, error)

Find fetches a single story record from the database by id.

func FindAll

func FindAll(q *query.Query) ([]*Story, error)

FindAll fetches all story records matching this query from the database.

func FindFirst

func FindFirst(format string, args ...interface{}) (*Story, error)

FindFirst fetches a single story record from the database using a where query with the format and args provided.

func New

func New() *Story

New creates and initialises a new story instance.

func NewWithColumns

func NewWithColumns(cols map[string]interface{}) *Story

NewWithColumns creates a new story instance and fills it with data from the database cols provided.

func (*Story) CanonicalURL

func (s *Story) CanonicalURL() string

CanonicalURL is the canonical URL of the story on this site including a slug for seo

func (*Story) Code

func (s *Story) Code() bool

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

func (s *Story) CommentCountDisplay() string

CommentCountDisplay returns the comment count or ellipsis if count is 0

func (*Story) CompleteURL

func (s *Story) CompleteURL() string

CompleteURL returns combination of protocol, root url and destination url

func (*Story) CountSubscribers

func (s *Story) CountSubscribers() int

func (*Story) DestinationURL

func (s *Story) DestinationURL() string

DestinationURL returns the URL of the story if no url is set, it uses the CanonicalURL

func (*Story) Domain

func (s *Story) Domain() string

Domain returns the domain of the story URL

func (*Story) Editable

func (s *Story) Editable() bool

Editable returns true if this story is editable. products are editable if less than 1 hours old

func (*Story) FileName

func (s *Story) FileName() string

FileName is the file friendly version of the product name

func (*Story) GetHashTag

func (s *Story) GetHashTag() []string

GetHashTag gives the hashtags in the name

func (*Story) GodocURL

func (s *Story) GodocURL() string

GodocURL returns the godoc.org URL for this story, or empty string if none

func (*Story) NameDisplay

func (s *Story) NameDisplay() string

NameDisplay returns a title string without hashtags (assumed to be at the end), by truncating the title at the first #

func (*Story) NegativePoints

func (s *Story) NegativePoints() int64

NegativePoints returns a negative point score or 0 if points is above 0

func (*Story) OwnedBy

func (s *Story) OwnedBy(uid int64) bool

OwnedBy returns true if this user id owns this story.

func (*Story) PermaURL

func (s *Story) PermaURL() string

func (*Story) PrimaryURL

func (s *Story) PrimaryURL() string

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) ShowAsk

func (s *Story) ShowAsk() bool

ShowAsk returns true if this is a Show: or Ask: story

func (*Story) Tags

func (s *Story) Tags() []string

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

func (*Story) VetURL

func (s *Story) VetURL() string

VetURL returns a URL for goreportcard.com, for code repos

func (*Story) YouTube

func (s *Story) YouTube() bool

YouTube returns true if this is a youtube video

func (*Story) YouTubeURL

func (s *Story) YouTubeURL() string

YouTubeURL returns the youtube URL

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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