db

package
v0.0.0-...-ca83848 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package db is a generated protocol buffer package.

It is generated from these files:

models.proto

It has these top-level messages:

User
Teammate
Collection
AuthToken
Session
Pageview

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrKeyExists is an error what you can get if the key exists but it shouldn't
	ErrKeyExists = cipobolt.ErrKeyExists
	// ErrKeyNotExists is an error what you can get if the key not exists but it should
	ErrKeyNotExists = cipobolt.ErrKeyNotExists
)
View Source
var (
	BUser       = []byte("User")
	BCollection = []byte("Collection")
	BSession    = []byte("Session")
	BPageview   = []byte("Pageview")
	BAuthToken  = []byte("AuthToken")
)

These are the bucket's names

Functions

func AddTeammate

func AddTeammate(collection *Collection, user *User) error

AddTeammate adds a Teammate to a user

func CountUsers

func CountUsers() (int, error)

CountUsers returns the count of the users

func DecodeSessionKey

func DecodeSessionKey(key string) ([]byte, error)

DecodeSessionKey decodes a session key from base64

func DeleteAuthToken

func DeleteAuthToken(id string) error

DeleteAuthToken deletes an authtoken

func DeleteCollection

func DeleteCollection(collection *Collection) error

DeleteCollection deletes a collection

func DeleteCollectionShard

func DeleteCollectionShard(collection *Collection, shardID string) error

DeleteCollectionShard deletes a shard from the collection

func DeleteUser

func DeleteUser(user *User) error

DeleteUser deletes an user

func EncodeSessionKey

func EncodeSessionKey(k []byte) string

EncodeSessionKey encodes a session key with base64

func GetIDFromKey

func GetIDFromKey(key []byte) uint32

GetIDFromKey returns the id based on key

func GetKey

func GetKey(t time.Time, id uint32) []byte

GetKey returns the databse key based on time and id

func GetKeyFromTime

func GetKeyFromTime(t time.Time) []byte

GetKeyFromTime returns a database key based on time

func GetPVKey

func GetPVKey(sessionkey []byte, t time.Time) []byte

GetPVKey returns the pageview key based on sessionkey and time

func GetTimeFromKey

func GetTimeFromKey(key []byte) time.Time

GetTimeFromKey returns the time based on key

func GetTimeFromPVKey

func GetTimeFromPVKey(key []byte) time.Time

GetTimeFromPVKey return the time from the pageview key

func InitDatabase

func InitDatabase(basedirParam string)

InitDatabase initializes the databases, creates the directories if necessary

func InsertAuthToken

func InsertAuthToken(token *AuthToken) error

InsertAuthToken inserts an authtoken

func InsertCollection

func InsertCollection(collection *Collection) error

InsertCollection inserts a new collection

func InsertUser

func InsertUser(user *User) error

InsertUser inserts an user

func RemoveTeammate

func RemoveTeammate(collection *Collection, ID uint64) error

RemoveTeammate removes a teammate by email

func RunBackup

func RunBackup(dir string) error

RunBackup copies the database to the dir

func Seed

func Seed(from time.Time, to time.Time, collectionID string, n int) error

Seed seeds a collection with n session

func ShardUpdate

func ShardUpdate(collectionID string, fn func(tx *shardbolt.MultiTx) error) error

ShardUpdate runs the fn in a shard

func ShardUpsert

func ShardUpsert(collectionID string, key []byte, v proto.Message) error

ShardUpsert upsert a value into shards

func ShardUpsertBatch

func ShardUpsertBatch(collectionID string, key []byte, v proto.Message) error

ShardUpsertBatch upsert a value into shards, but not in a separated transaction

func ShardUpsertTx

func ShardUpsertTx(tx *shardbolt.MultiTx, key []byte, v proto.Message) error

ShardUpsertTx upsert a value into shards in a transaction

func UpdateAuthToken

func UpdateAuthToken(token *AuthToken) error

UpdateAuthToken updates an authtoken

func UpdateCollection

func UpdateCollection(collection *Collection) error

UpdateCollection updates a new collection

func UpdateUser

func UpdateUser(user *User) error

UpdateUser updates an user

func UserIsTeammate

func UserIsTeammate(collection *Collection, ID uint64) bool

UserIsTeammate check whether the User inside the collection's team

Types

type AuthToken

type AuthToken struct {
	ID      string `protobuf:"bytes,1,opt,name=ID,json=iD" json:"ID,omitempty"`
	OwnerID uint64 `protobuf:"varint,2,opt,name=OwnerID,json=ownerID" json:"OwnerID,omitempty"`
	TTL     int32  `protobuf:"varint,3,opt,name=TTL,json=tTL" json:"TTL,omitempty"`
	Created int64  `protobuf:"varint,4,opt,name=Created,json=created" json:"Created,omitempty"`
}

func GetAuthToken

func GetAuthToken(id string) (*AuthToken, error)

GetAuthToken returns an authtoken with the id parameter

func (*AuthToken) Descriptor

func (*AuthToken) Descriptor() ([]byte, []int)

func (*AuthToken) GetCreated

func (m *AuthToken) GetCreated() int64

func (*AuthToken) GetID

func (m *AuthToken) GetID() string

func (*AuthToken) GetOwnerID

func (m *AuthToken) GetOwnerID() uint64

func (*AuthToken) GetTTL

func (m *AuthToken) GetTTL() int32

func (*AuthToken) ProtoMessage

func (*AuthToken) ProtoMessage()

func (*AuthToken) Reset

func (m *AuthToken) Reset()

func (*AuthToken) String

func (m *AuthToken) String() string

type Collection

type Collection struct {
	ID        string      `protobuf:"bytes,1,opt,name=ID,json=iD" json:"ID,omitempty"`
	OwnerID   uint64      `protobuf:"varint,2,opt,name=OwnerID,json=ownerID" json:"OwnerID,omitempty"`
	Name      string      `protobuf:"bytes,3,opt,name=Name,json=name" json:"Name,omitempty"`
	Teammates []*Teammate `protobuf:"bytes,4,rep,name=Teammates,json=teammates" json:"Teammates,omitempty"`
	Created   int64       `protobuf:"varint,5,opt,name=Created,json=created" json:"Created,omitempty"`
}

func GetCollection

func GetCollection(id string) (*Collection, error)

GetCollection returns a collection with the id parameter

func GetCollectionByName

func GetCollectionByName(ownerID uint64, name string) (*Collection, error)

GetCollectionByName returns a collection

func GetCollections

func GetCollections() ([]Collection, error)

GetCollections returns all the collections

func GetCollectionsByUserID

func GetCollectionsByUserID(ID uint64) ([]Collection, error)

GetCollectionsByUserID returns collections accessible by the user

func GetCollectionsOwnedByUser

func GetCollectionsOwnedByUser(ID uint64) ([]Collection, error)

GetCollectionsOwnedByUser returns the collections owned by user

func (*Collection) Descriptor

func (*Collection) Descriptor() ([]byte, []int)

func (*Collection) GetCreated

func (m *Collection) GetCreated() int64

func (*Collection) GetID

func (m *Collection) GetID() string

func (*Collection) GetName

func (m *Collection) GetName() string

func (*Collection) GetOwnerID

func (m *Collection) GetOwnerID() uint64

func (*Collection) GetTeammates

func (m *Collection) GetTeammates() []*Teammate

func (*Collection) ProtoMessage

func (*Collection) ProtoMessage()

func (*Collection) Reset

func (m *Collection) Reset()

func (*Collection) String

func (m *Collection) String() string

type CollectionDataInputT

type CollectionDataInputT struct {
	From     time.Time
	To       time.Time
	Bucket   string
	Timezone string
	Filter   map[string]string
}

CollectionDataInputT is the input filter struct for the clients

type CollectionDataT

type CollectionDataT struct {
	ID           string        `json:"id"`
	Name         string        `json:"name"`
	OwnerName    string        `json:"owner_name"`
	SessionSums  []*bucketSumT `json:"session_sums"`
	PageviewSums []*bucketSumT `json:"pageview_sums"`
}

CollectionDataT is the collection's data struct for the clients

func GetBucketSums

func GetBucketSums(collection *Collection, input *CollectionDataInputT) (*CollectionDataT, error)

GetBucketSums returns the bucket by hour or day or week or month

type CollectionStatDataT

type CollectionStatDataT struct {
	SessionTotal         totalT   `json:"session_total"`
	PageviewTotal        totalT   `json:"pageview_total"`
	AvgSessionLength     totalT   `json:"avg_session_length"`
	BounceRate           percentT `json:"bounce_rate"`
	PageSums             []sumT   `json:"page_sums"`
	QueryStringSums      []sumT   `json:"query_string_sums"`
	HostnameSums         []sumT   `json:"hostname_sums"`
	DeviceTypeSums       []sumT   `json:"device_type_sums"`
	DeviceOSSums         []sumT   `json:"device_os_sums"`
	BrowserNameSums      []sumT   `json:"browser_name_sums"`
	BrowserVersionSums   []sumT   `json:"browser_version_sums"`
	BrowserLanguageSums  []sumT   `json:"browser_language_sums"`
	PageviewCountSums    []sumT   `json:"pageview_count_sums"`
	ScreenResolutionSums []sumT   `json:"screen_resolution_sums"`
	WindowResolutionSums []sumT   `json:"window_resolution_sums"`
	CountryCodeSums      []sumT   `json:"country_code_sums"`
	CitySums             []sumT   `json:"city_sums"`
	ASNameSums           []sumT   `json:"as_name_sums"`
	ReferrerSums         []sumT   `json:"referrer_sums"`
}

CollectionStatDataT is the collection's statistic data struct for the clients

func GetStatistics

func GetStatistics(collection *Collection, input *CollectionDataInputT) (*CollectionStatDataT, error)

GetStatistics returns the statistic data for the collection

type CollectionSummary

type CollectionSummary struct {
	SessionCount    int           `json:"session_count"`
	SessionPercent  float32       `json:"session_percent"`
	SessionSums     []*bucketSumT `json:"session_sums"`
	PageviewCount   int           `json:"pageview_count"`
	PageviewPercent float32       `json:"pageview_percent"`
	PageviewSums    []*bucketSumT `json:"pageview_sums"`
}

CollectionSummary contains summary for the collection

func GetCollectionSummary

func GetCollectionSummary(collectionID string, dayBefore int, options CollectionSummaryOptions) (CollectionSummary, error)

GetCollectionSummary returns the last daybefore days versus the previous daybefore days summary

type CollectionSummaryOptions

type CollectionSummaryOptions struct {
	Timezone string `json:"timezone"`
}

CollectionSummaryOptions contains the options for the GetColectionSummary function

type ExtPageview

type ExtPageview struct {
	Pageview
	Time time.Time
}

ExtPageview extends the Pageview proto struct with calculated information

type ExtSession

type ExtSession struct {
	Session
	Key           string
	Begin         time.Time
	PageviewCount int
}

ExtSession extends the Session proto struct with calculated information

type Pageview

type Pageview struct {
	Path        string `protobuf:"bytes,1,opt,name=Path,json=path" json:"Path,omitempty"`
	QueryString string `protobuf:"bytes,2,opt,name=QueryString,json=queryString" json:"QueryString,omitempty"`
}

func (*Pageview) Descriptor

func (*Pageview) Descriptor() ([]byte, []int)

func (*Pageview) GetPath

func (m *Pageview) GetPath() string

func (*Pageview) GetQueryString

func (m *Pageview) GetQueryString() string

func (*Pageview) ProtoMessage

func (*Pageview) ProtoMessage()

func (*Pageview) Reset

func (m *Pageview) Reset()

func (*Pageview) String

func (m *Pageview) String() string

type PageviewDataT

type PageviewDataT struct {
	Time        int64  `json:"time"`
	Path        string `json:"path"`
	QueryString string `json:"query_string"`
}

PageviewDataT is the pageview data struct for the clients

func GetPageviews

func GetPageviews(collection *Collection, sessionKey []byte) ([]*PageviewDataT, error)

GetPageviews returns the session's pageviews

type Session

type Session struct {
	Duration         int32  `protobuf:"varint,1,opt,name=Duration,json=duration" json:"Duration,omitempty"`
	Hostname         string `protobuf:"bytes,2,opt,name=Hostname,json=hostname" json:"Hostname,omitempty"`
	DeviceOS         string `protobuf:"bytes,3,opt,name=DeviceOS,json=deviceOS" json:"DeviceOS,omitempty"`
	BrowserName      string `protobuf:"bytes,4,opt,name=BrowserName,json=browserName" json:"BrowserName,omitempty"`
	BrowserVersion   string `protobuf:"bytes,5,opt,name=BrowserVersion,json=browserVersion" json:"BrowserVersion,omitempty"`
	BrowserLanguage  string `protobuf:"bytes,6,opt,name=BrowserLanguage,json=browserLanguage" json:"BrowserLanguage,omitempty"`
	ScreenResolution string `protobuf:"bytes,7,opt,name=ScreenResolution,json=screenResolution" json:"ScreenResolution,omitempty"`
	WindowResolution string `protobuf:"bytes,8,opt,name=WindowResolution,json=windowResolution" json:"WindowResolution,omitempty"`
	DeviceType       string `protobuf:"bytes,9,opt,name=DeviceType,json=deviceType" json:"DeviceType,omitempty"`
	CountryCode      string `protobuf:"bytes,10,opt,name=CountryCode,json=countryCode" json:"CountryCode,omitempty"`
	City             string `protobuf:"bytes,11,opt,name=City,json=city" json:"City,omitempty"`
	UserAgent        string `protobuf:"bytes,12,opt,name=UserAgent,json=userAgent" json:"UserAgent,omitempty"`
	UserIP           string `protobuf:"bytes,13,opt,name=UserIP,json=userIP" json:"UserIP,omitempty"`
	UserHostname     string `protobuf:"bytes,14,opt,name=UserHostname,json=userHostname" json:"UserHostname,omitempty"`
	Referrer         string `protobuf:"bytes,15,opt,name=Referrer,json=referrer" json:"Referrer,omitempty"`
	ASNumber         int32  `protobuf:"varint,16,opt,name=ASNumber,json=aSNumber" json:"ASNumber,omitempty"`
	ASName           string `protobuf:"bytes,17,opt,name=ASName,json=aSName" json:"ASName,omitempty"`
}

func GetSession

func GetSession(collectionID string, key []byte) (*Session, error)

GetSession returns a session

func (*Session) Descriptor

func (*Session) Descriptor() ([]byte, []int)

func (*Session) GetASName

func (m *Session) GetASName() string

func (*Session) GetASNumber

func (m *Session) GetASNumber() int32

func (*Session) GetBrowserLanguage

func (m *Session) GetBrowserLanguage() string

func (*Session) GetBrowserName

func (m *Session) GetBrowserName() string

func (*Session) GetBrowserVersion

func (m *Session) GetBrowserVersion() string

func (*Session) GetCity

func (m *Session) GetCity() string

func (*Session) GetCountryCode

func (m *Session) GetCountryCode() string

func (*Session) GetDeviceOS

func (m *Session) GetDeviceOS() string

func (*Session) GetDeviceType

func (m *Session) GetDeviceType() string

func (*Session) GetDuration

func (m *Session) GetDuration() int32

func (*Session) GetHostname

func (m *Session) GetHostname() string

func (*Session) GetReferrer

func (m *Session) GetReferrer() string

func (*Session) GetScreenResolution

func (m *Session) GetScreenResolution() string

func (*Session) GetUserAgent

func (m *Session) GetUserAgent() string

func (*Session) GetUserHostname

func (m *Session) GetUserHostname() string

func (*Session) GetUserIP

func (m *Session) GetUserIP() string

func (*Session) GetWindowResolution

func (m *Session) GetWindowResolution() string

func (*Session) ProtoMessage

func (*Session) ProtoMessage()

func (*Session) Reset

func (m *Session) Reset()

func (*Session) String

func (m *Session) String() string

type SessionDataT

type SessionDataT struct {
	Key              string `json:"key"`
	Hostname         string `json:"hostname"`
	DeviceOS         string `json:"device_os"`
	BrowserName      string `json:"browser_name"`
	BrowserVersion   string `json:"browser_version"`
	BrowserLanguage  string `json:"browser_language"`
	ScreenResolution string `json:"screen_resolution"`
	WindowResolution string `json:"window_resolution"`
	DeviceType       string `json:"device_type"`
	CountryCode      string `json:"country_code"`
	City             string `json:"city"`
	ASNumber         int32  `json:"as_number"`
	ASName           string `json:"as_name"`
	UserAgent        string `json:"user_agent"`
	UserIP           string `json:"user_ip"`
	UserHostname     string `json:"user_hostname"`
	Begin            int64  `json:"begin"`
	Duration         int32  `json:"duration"`
	PageviewCount    int    `json:"pageview_count"`
	Referrer         string `json:"referrer"`
}

SessionDataT is the session data struct for the clients

func GetSessions

func GetSessions(collection *Collection, input *CollectionDataInputT) ([]*SessionDataT, error)

GetSessions returns the collection's sessions

type ShardDataT

type ShardDataT struct {
	ID   string `json:"id"`
	Size int    `json:"size"`
}

ShardDataT is the shard data struct for the clients

func GetCollectionShardDatas

func GetCollectionShardDatas(collection *Collection) ([]ShardDataT, error)

GetCollectionShardDatas returns the collection's shards information

type Teammate

type Teammate struct {
	ID uint64 `protobuf:"varint,1,opt,name=ID,json=iD" json:"ID,omitempty"`
}

func GetTeammate

func GetTeammate(collection *Collection, ID uint64) *Teammate

GetTeammate returns the teammate by ID

func (*Teammate) Descriptor

func (*Teammate) Descriptor() ([]byte, []int)

func (*Teammate) GetID

func (m *Teammate) GetID() uint64

func (*Teammate) ProtoMessage

func (*Teammate) ProtoMessage()

func (*Teammate) Reset

func (m *Teammate) Reset()

func (*Teammate) String

func (m *Teammate) String() string

type User

type User struct {
	ID                   uint64 `protobuf:"varint,1,opt,name=ID,json=iD" json:"ID,omitempty"`
	Email                string `protobuf:"bytes,2,opt,name=Email,json=email" json:"Email,omitempty"`
	Password             string `protobuf:"bytes,3,opt,name=Password,json=password" json:"Password,omitempty"`
	Created              int64  `protobuf:"varint,4,opt,name=Created,json=created" json:"Created,omitempty"`
	Name                 string `protobuf:"bytes,5,opt,name=Name,json=name" json:"Name,omitempty"`
	IsAdmin              bool   `protobuf:"varint,10,opt,name=IsAdmin,json=isAdmin" json:"IsAdmin,omitempty"`
	DisablePwChange      bool   `protobuf:"varint,11,opt,name=DisablePwChange,json=disablePwChange" json:"DisablePwChange,omitempty"`
	LimitCollections     bool   `protobuf:"varint,12,opt,name=LimitCollections,json=limitCollections" json:"LimitCollections,omitempty"`
	CollectionLimit      uint32 `protobuf:"varint,13,opt,name=CollectionLimit,json=collectionLimit" json:"CollectionLimit,omitempty"`
	DisableUserDeletion  bool   `protobuf:"varint,14,opt,name=DisableUserDeletion,json=disableUserDeletion" json:"DisableUserDeletion,omitempty"`
	EmailVerified        bool   `protobuf:"varint,20,opt,name=EmailVerified,json=emailVerified" json:"EmailVerified,omitempty"`
	EmailVerificationKey string `protobuf:"bytes,21,opt,name=EmailVerificationKey,json=emailVerificationKey" json:"EmailVerificationKey,omitempty"`
	EmailVerificationAt  int64  `protobuf:"varint,22,opt,name=EmailVerificationAt,json=emailVerificationAt" json:"EmailVerificationAt,omitempty"`
	PasswordResetKey     string `protobuf:"bytes,23,opt,name=PasswordResetKey,json=passwordResetKey" json:"PasswordResetKey,omitempty"`
	PasswordResetAt      int64  `protobuf:"varint,24,opt,name=PasswordResetAt,json=passwordResetAt" json:"PasswordResetAt,omitempty"`
}

func GetAdminUsers

func GetAdminUsers() ([]User, error)

GetAdminUsers returns the admin users

func GetUserByEmail

func GetUserByEmail(email string) (*User, error)

GetUserByEmail returns an user with the email parameter

func GetUserByID

func GetUserByID(ID uint64) (*User, error)

GetUserByID returns an user with the email parameter

func GetUserByName

func GetUserByName(name string) (*User, error)

GetUserByName returns an user with the name parameter

func GetUsers

func GetUsers() ([]User, error)

GetUsers returns the users

func (*User) Descriptor

func (*User) Descriptor() ([]byte, []int)

func (*User) GetCollectionLimit

func (m *User) GetCollectionLimit() uint32

func (*User) GetCreated

func (m *User) GetCreated() int64

func (*User) GetDisablePwChange

func (m *User) GetDisablePwChange() bool

func (*User) GetDisableUserDeletion

func (m *User) GetDisableUserDeletion() bool

func (*User) GetEmail

func (m *User) GetEmail() string

func (*User) GetEmailVerificationAt

func (m *User) GetEmailVerificationAt() int64

func (*User) GetEmailVerificationKey

func (m *User) GetEmailVerificationKey() string

func (*User) GetEmailVerified

func (m *User) GetEmailVerified() bool

func (*User) GetID

func (m *User) GetID() uint64

func (*User) GetIsAdmin

func (m *User) GetIsAdmin() bool

func (*User) GetLimitCollections

func (m *User) GetLimitCollections() bool

func (*User) GetName

func (m *User) GetName() string

func (*User) GetPassword

func (m *User) GetPassword() string

func (*User) GetPasswordResetAt

func (m *User) GetPasswordResetAt() int64

func (*User) GetPasswordResetKey

func (m *User) GetPasswordResetKey() string

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) Reset

func (m *User) Reset()

func (*User) String

func (m *User) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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