models

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package models describes models for database communication.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidUsersBatchType = errors.New("invalid users batch type")

ErrInvalidUsersBatchType means that batch type not supported.

Functions

func MakeInvalidBatchTypeError

func MakeInvalidBatchTypeError(t UsersBatchType) error

MakeInvalidBatchTypeError returns ErrInvalidUsersBatchType with added bathtype info.

Types

type DiffHistory added in v1.1.0

type DiffHistory struct {
	DiffType DiffType
	History  map[time.Time][]UsersBatch
}

DiffHistory represents history of account changes.

func MakeDiffHistory added in v1.1.0

func MakeDiffHistory(dt DiffType) DiffHistory

MakeDiffHistory constructs DiffHistory.

func (*DiffHistory) Add added in v1.1.0

func (d *DiffHistory) Add(batches ...UsersBatch)

Add adds user batch to the history.

func (*DiffHistory) Get added in v1.1.0

func (d *DiffHistory) Get(date time.Time) []UsersBatch

Get returns all UsersBatch for specified date.

type DiffType added in v1.1.0

type DiffType uint

DiffType marks what is the type of diff hostory is.

const (
	// DiffTypeUnknown is unknown type, to cover default value case.
	DiffTypeUnknown DiffType = iota

	// DiffTypeFollowers represents followers history.
	DiffTypeFollowers
	// DiffTypeFollowings represents followings history.
	DiffTypeFollowings
)

func (DiffType) String added in v1.1.0

func (i DiffType) String() string

type Limits

type Limits struct {
	Follow   int
	UnFollow int
}

Limits represents action limits.

type User

type User struct {
	ID       int64  `bson:"id"`
	UserName string `bson:"user_name"`
	FullName string `bson:"full_name"`
}

User stores information about user.

func MakeUser

func MakeUser(id int64, username, fullname string) User

MakeUser creates User with passed values.

type UsersBatch

type UsersBatch struct {
	Users     []User         `bson:"users"`
	Type      UsersBatchType `bson:"batch_type"`
	CreatedAt time.Time      `bson:"created_at"`
}

UsersBatch represents info about specific type of users (followers, followings).

func MakeUsersBatch added in v1.1.0

func MakeUsersBatch(bt UsersBatchType, users []User, created time.Time) UsersBatch

MakeUsersBatch constructs UsersBatch.

type UsersBatchType

type UsersBatchType int

UsersBatchType marks what is the type of users stored in the batch.

const (
	// UsersBatchTypeUnknown is unknown type, to cover default value case.
	UsersBatchTypeUnknown UsersBatchType = iota

	// UsersBatchTypeFollowers represents user's followers.
	UsersBatchTypeFollowers
	// UsersBatchTypeFollowings represents user's followings.
	UsersBatchTypeFollowings
	// UsersBatchTypeNotMutual represents users that not following back.
	UsersBatchTypeNotMutual
	// UsersBatchTypeUselessFollowers represents business accounts, bots and mass followers.
	UsersBatchTypeUselessFollowers
	// UsersBatchTypeLostFollowers represents lost followers.
	UsersBatchTypeLostFollowers
	// UsersBatchTypeNewFollowers represents new followers.
	UsersBatchTypeNewFollowers
	// UsersBatchTypeNewFollowings represents new followings.
	UsersBatchTypeNewFollowings
	// UsersBatchTypeLostFollowings represents lost followings.
	UsersBatchTypeLostFollowings
)

func (UsersBatchType) String

func (i UsersBatchType) String() string

func (UsersBatchType) Valid

func (i UsersBatchType) Valid() bool

Valid checks if value is valid type.

Jump to

Keyboard shortcuts

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