Documentation ¶
Overview ¶
Package models describes models for database communication.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.
type User ¶
type User struct { ID int64 `bson:"id"` UserName string `bson:"user_name"` FullName string `bson:"full_name"` }
User stores information about user.
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.