model

package
v0.0.0-...-0a03112 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package model contains data for reaction.pics

Index

Constants

View Source
const (
	MaxKeywords = 20
)

MaxKeywords is the maximum number of keywords that can be returned by a board

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

type Board struct {
	Posts []Post
	// contains filtered or unexported fields
}

Board is a container for Posts that offers serialization, sorting, and parallelization

func InitializeBoard

func InitializeBoard() *Board

InitializeBoard means to create a new board and start writing reading saved posts into it

func NewBoard

func NewBoard(p []Post) Board

NewBoard creates a Board from an array of Posts

func (*Board) AddPost

func (b *Board) AddPost(p Post)

AddPost adds a single post to the board; no-ops if the post is already present

func (Board) FilterBoard

func (b Board) FilterBoard(queries []string) *Board

FilterBoard returns a new Board with a subset of posts filtered by a string

func (Board) GetPostByID

func (b Board) GetPostByID(postID int64) *Post

GetPostByID returns a post that matches the postID

func (Board) Keywords

func (b Board) Keywords() []string

Keywords returns the most popular words in posts

func (*Board) LimitBoard

func (b *Board) LimitBoard(offset, maxResults int)

LimitBoard modifies the current board with maxResults posts starting at offset

func (Board) MarshalJSON

func (b Board) MarshalJSON() ([]byte, error)

MarshalJSON allows Board to be converted to json

func (*Board) PopulateBoard

func (b *Board) PopulateBoard()

PopulateBoard adds production posts to the board

func (*Board) RandomizePosts

func (b *Board) RandomizePosts()

RandomizePosts will shuffle the current Board's posts

func (*Board) SortPostsByLikes

func (b *Board) SortPostsByLikes()

SortPostsByLikes sorts Posts in reverse number of likes order

func (Board) URLs

func (b Board) URLs() []string

URLs returns an array of URLs of all the posts

type Post

type Post struct {
	ID    int64  `json:"id"`
	Title string `json:"title"`
	URL   string `json:"url"`
	Image string `json:"image"`
	Likes int64  `json:"likes"`
}

Post is a representation of a single tumblr post

func CSVToPost

func CSVToPost(row []string) *Post

CSVToPost converts a CSV row into a Post

func ReadPostsFromCSV

func ReadPostsFromCSV(csvData []byte) []Post

ReadPostsFromCSV reads a CSV file into a list of posts

func (Post) InternalURL

func (p Post) InternalURL() string

InternalURL returns the path to the post

func (Post) MarshalJSON

func (p Post) MarshalJSON() ([]byte, error)

MarshalJSON allows Post to be converted to json

Jump to

Keyboard shortcuts

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