client

package
v0.0.0-...-1fca3aa Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emoji

type Emoji struct {
	EmojiPair
	Created  time.Time     `firestore:"created"`
	Uses     int           `firestore:"uses"`               // total use count
	Last     time.Time     `firestore:"last,omitempty"`     // last use at
	Recent   float64       `firestore:"recent"`             // recent use count
	RecentAt time.Time     `firestore:"recentAt,omitempty"` // recent use adjusted at
	Duration time.Duration `firestore:"duration"`           // drifted time between use
	Source   string        `firestore:"source,omitempty"`   // original import source
	Length   int           `firestore:"len,omitempty"`      // emoji visible length
	Version  int           `firestore:"v,omitempty"`        // revision in db

	Index map[string]float64 `firestore:"i,omitempty"` // all index components by prefix
}

Emoji is an Emoji stored in Firestore.

func (*Emoji) DurationAt

func (e *Emoji) DurationAt(t time.Time) time.Duration

DurationAt returns the drifted duration assuming a new use right now.

func (*Emoji) RecentFor

func (e *Emoji) RecentFor(t time.Time) float64

RecentFor returns the diminished use count by the constants above (50% over a week).

type EmojiClient

type EmojiClient struct {
	Context context.Context
	Client  *firestore.Client
	Count   func(string) int
}

EmojiClient is an interface to Firestore to retrieve and update Emoji.

func (*EmojiClient) Delete

func (ec *EmojiClient) Delete(all []EmojiPair) (int, error)

func (*EmojiClient) ForAdmin

func (ec *EmojiClient) ForAdmin(by string, limit int) ([]*Emoji, error)

func (*EmojiClient) Import

func (ec *EmojiClient) Import(all []*Emoji) (int, error)

func (*EmojiClient) Name

func (ec *EmojiClient) Name(pair EmojiPair, source string) error

func (*EmojiClient) Popular

func (ec *EmojiClient) Popular(limit int) ([]EmojiPair, error)

func (*EmojiClient) Query

func (ec *EmojiClient) Query(query string, prefix bool, limit int) ([]EmojiPair, error)

func (*EmojiClient) Ref

Ref returns the firestore.DocumentRef for this EmojiPair, or nil if invalid.

func (*EmojiClient) Select

func (ec *EmojiClient) Select(all []EmojiPair) error

func (*EmojiClient) Touch

func (ec *EmojiClient) Touch(all []*Emoji) (int, error)

type EmojiPair

type EmojiPair struct {
	Name  string `firestore:"name" json:"name"`
	Emoji string `firestore:"emoji" json:"emoji"`
}

EmojiPair is an emoji and its name.

func Decode

func Decode(id string) (out EmojiPair, ok bool)

Decode decodes the ID part of a DocumentRef into an EmojiPair, if possible.

func (*EmojiPair) ID

func (ep *EmojiPair) ID() string

ID returns the Doc key of this EmojiPair, escaped for Firestore/Datastore.

func (*EmojiPair) Valid

func (ep *EmojiPair) Valid() bool

Valid returns whether this EmojiPair has name and emoji.

Jump to

Keyboard shortcuts

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