tweets

package
v0.0.0-...-c38155f Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package tweets provides functionality around reading and writing tweets.

Package tweets provides functionality around reading and writing tweets.

Package tweets provides functionality around reading and writing tweets.

Index

Constants

View Source
const (
	// DBName is the name of the database for the tweets API.
	DBName = "tweets"
)

Variables

This section is empty.

Functions

func CreateEmojisTableIfNotExist

func CreateEmojisTableIfNotExist(db *sql.DB) error

CreateEmojisTableIfNotExist creates the "emojis" table if it does not exist already.

func CreateTweetsTableIfNotExist

func CreateTweetsTableIfNotExist(db *sql.DB) error

CreateTweetsTableIfNotExist creates the "tweets" table if it does not exist already.

Types

type DB

type DB interface {
	StoreTweet(id, username, tweetContent, createdAt, metadata string) error
	ExistTweet(id string) (bool, error)
	StoreEmoji(id, emoji string) error
	EmojiResults() partialQuery
}

DB is the interface for all the operations allowed on tweets.

func NewSQLDB

func NewSQLDB(db *sql.DB) DB

NewSQLDB creates a sql database to read and store tweets.

type EmojiCount

type EmojiCount struct {
	Emoji string `json:"emoji"`
	Count int    `json:"count"`
}

EmojiCount is a pair of a emoji and the count of occurrences of emoji.

type EmojisController

type EmojisController interface {
	EmojiResults() ([]EmojiCount, error)
}

func NewEmojisController

func NewEmojisController(db DB) EmojisController

type Tweet

type Tweet struct {
	ID           string       `json:"id"`
	Username     string       `json:"username"`
	TweetContent string       `json:"tweet_content"`
	Metadata     TweetMetdata `json:"metadata"`
}

type TweetMetdata

type TweetMetdata struct {
	Media       string `json:"media"`
	HashTags    string `json:"hashtags"`
	CreatedAt   string `json:"created_date"`
	RetweetData string `json:"retweet_data"`
}

type TweetsController

type TweetsController interface {
	StoreTweet(t Tweet) error
}

func NewTweetsController

func NewTweetsController(db DB) TweetsController

Jump to

Keyboard shortcuts

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