statsstore

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

README

Stats Store

Open in Gitpod

Tests Status Go Report Card PkgGoDev

Stats Store - a visitor stats storage implementation for Go.

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). You can find a copy of the license at https://www.gnu.org/licenses/agpl-3.0.en.html

For commercial use, please use my contact page to obtain a commercial license.

Installation

go get -u github.com/gouniverse/statsstore

Setup

store, err := NewStore(NewStoreOptions{
	VisitorTableName:     "stats_visitor",
	DB:                 databaseInstance,
	AutomigrateEnabled: true,
})

Documentation

Index

Constants

View Source
const COLUMN_COUNTRY = "country"
View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_DELETED_AT = "deleted_at"
View Source
const COLUMN_FINGERPRINT = "fingerprint"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_IP_ADDRESS = "ip_address"
View Source
const COLUMN_PATH = "path"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const COLUMN_USER_ACCEPT_ENCODING = "user_accept_encoding"
View Source
const COLUMN_USER_ACCEPT_LANGUAGE = "user_accept_language"
View Source
const COLUMN_USER_AGENT = "user_agent"
View Source
const COLUMN_USER_BROWSER = "user_browser"
View Source
const COLUMN_USER_BROWSER_VERSION = "user_browser_version"
View Source
const COLUMN_USER_DEVICE = "user_device"
View Source
const COLUMN_USER_DEVICE_TYPE = "user_device_type"
View Source
const COLUMN_USER_OS = "user_os"
View Source
const COLUMN_USER_OS_VERSION = "user_os_version"
View Source
const COLUMN_USER_REFERRER = "user_referrer"

Variables

This section is empty.

Functions

This section is empty.

Types

type NewStoreOptions

type NewStoreOptions struct {
	VisitorTableName   string
	DB                 *sql.DB
	DbDriverName       string
	AutomigrateEnabled bool
	DebugEnabled       bool
}

NewStoreOptions define the options for creating a new block store

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(opts NewStoreOptions) (*Store, error)

NewStore creates a new block store

func (*Store) AutoMigrate

func (store *Store) AutoMigrate() error

AutoMigrate auto migrate

func (*Store) DB added in v0.3.0

func (store *Store) DB() *sql.DB

DB returns the database

func (*Store) EnableDebug

func (st *Store) EnableDebug(debug bool)

EnableDebug - enables the debug option

func (*Store) VisitorCount

func (store *Store) VisitorCount(ctx context.Context, options VisitorQueryOptions) (int64, error)

func (*Store) VisitorCreate

func (store *Store) VisitorCreate(ctx context.Context, visitor VisitorInterface) error

func (*Store) VisitorDelete

func (store *Store) VisitorDelete(ctx context.Context, visitor VisitorInterface) error

func (*Store) VisitorDeleteByID

func (store *Store) VisitorDeleteByID(ctx context.Context, id string) error

func (*Store) VisitorFindByID

func (store *Store) VisitorFindByID(ctx context.Context, id string) (VisitorInterface, error)

func (*Store) VisitorList

func (store *Store) VisitorList(ctx context.Context, options VisitorQueryOptions) ([]VisitorInterface, error)

func (*Store) VisitorRegister

func (store *Store) VisitorRegister(ctx context.Context, r *http.Request) error

func (*Store) VisitorSoftDelete

func (store *Store) VisitorSoftDelete(ctx context.Context, visitor VisitorInterface) error

func (*Store) VisitorSoftDeleteByID

func (store *Store) VisitorSoftDeleteByID(ctx context.Context, id string) error

func (*Store) VisitorUpdate

func (store *Store) VisitorUpdate(ctx context.Context, visitor VisitorInterface) error

type StoreInterface

type StoreInterface interface {
	AutoMigrate() error
	DB() *sql.DB
	EnableDebug(debug bool)
	VisitorCount(ctx context.Context, options VisitorQueryOptions) (int64, error)
	VisitorCreate(ctx context.Context, user VisitorInterface) error
	VisitorDelete(ctx context.Context, user VisitorInterface) error
	VisitorDeleteByID(ctx context.Context, id string) error
	VisitorFindByID(ctx context.Context, userID string) (VisitorInterface, error)
	VisitorList(ctx context.Context, options VisitorQueryOptions) ([]VisitorInterface, error)
	VisitorRegister(ctx context.Context, r *http.Request) error
	VisitorSoftDelete(ctx context.Context, user VisitorInterface) error
	VisitorSoftDeleteByID(ctx context.Context, id string) error
	VisitorUpdate(ctx context.Context, user VisitorInterface) error
}

type Visitor

type Visitor struct {
	dataobject.DataObject
}

func (*Visitor) Country

func (visitor *Visitor) Country() string

func (*Visitor) CreatedAt

func (visitor *Visitor) CreatedAt() string

func (*Visitor) CreatedAtCarbon

func (visitor *Visitor) CreatedAtCarbon() carbon.Carbon

func (*Visitor) DeletedAt

func (visitor *Visitor) DeletedAt() string

func (*Visitor) DeletedAtCarbon

func (visitor *Visitor) DeletedAtCarbon() carbon.Carbon

func (*Visitor) Fingerprint added in v0.1.0

func (visitor *Visitor) Fingerprint() string

func (*Visitor) FingerprintCalculate added in v0.1.0

func (visitor *Visitor) FingerprintCalculate() string

func (*Visitor) ID

func (visitor *Visitor) ID() string

func (*Visitor) IpAddress

func (visitor *Visitor) IpAddress() string

func (*Visitor) Path

func (visitor *Visitor) Path() string

func (*Visitor) SetCountry

func (visitor *Visitor) SetCountry(country string) VisitorInterface

func (*Visitor) SetCreatedAt

func (visitor *Visitor) SetCreatedAt(createdAt string) VisitorInterface

func (*Visitor) SetDeletedAt

func (visitor *Visitor) SetDeletedAt(deletedAt string) VisitorInterface

func (*Visitor) SetFingerprint added in v0.1.0

func (visitor *Visitor) SetFingerprint(fingerprint string) VisitorInterface

func (*Visitor) SetID

func (visitor *Visitor) SetID(id string) VisitorInterface

func (*Visitor) SetIpAddress

func (visitor *Visitor) SetIpAddress(ipAddress string) VisitorInterface

func (*Visitor) SetPath

func (visitor *Visitor) SetPath(path string) VisitorInterface

func (*Visitor) SetUpdatedAt

func (visitor *Visitor) SetUpdatedAt(updatedAt string) VisitorInterface

func (*Visitor) SetUserAcceptEncoding

func (visitor *Visitor) SetUserAcceptEncoding(userAcceptEncoding string) VisitorInterface

func (*Visitor) SetUserAcceptLanguage

func (visitor *Visitor) SetUserAcceptLanguage(userAcceptLanguage string) VisitorInterface

func (*Visitor) SetUserAgent

func (visitor *Visitor) SetUserAgent(userAgent string) VisitorInterface

func (*Visitor) SetUserBrowser

func (visitor *Visitor) SetUserBrowser(userBrowser string) VisitorInterface

func (*Visitor) SetUserBrowserVersion

func (visitor *Visitor) SetUserBrowserVersion(userBrowserVersion string) VisitorInterface

func (*Visitor) SetUserDevice

func (visitor *Visitor) SetUserDevice(userDevice string) VisitorInterface

func (*Visitor) SetUserDeviceType

func (visitor *Visitor) SetUserDeviceType(userDeviceType string) VisitorInterface

func (*Visitor) SetUserOs

func (visitor *Visitor) SetUserOs(userOs string) VisitorInterface

func (*Visitor) SetUserOsVersion

func (visitor *Visitor) SetUserOsVersion(userOsVersion string) VisitorInterface

func (*Visitor) SetUserReferrer

func (visitor *Visitor) SetUserReferrer(userReferrer string) VisitorInterface

func (*Visitor) UpdatedAt

func (visitor *Visitor) UpdatedAt() string

func (*Visitor) UpdatedAtCarbon

func (visitor *Visitor) UpdatedAtCarbon() carbon.Carbon

func (*Visitor) UserAcceptEncoding

func (visitor *Visitor) UserAcceptEncoding() string

func (*Visitor) UserAcceptLanguage

func (visitor *Visitor) UserAcceptLanguage() string

func (*Visitor) UserAgent

func (visitor *Visitor) UserAgent() string

func (*Visitor) UserBrowser

func (visitor *Visitor) UserBrowser() string

func (*Visitor) UserBrowserVersion

func (visitor *Visitor) UserBrowserVersion() string

func (*Visitor) UserDevice

func (visitor *Visitor) UserDevice() string

func (*Visitor) UserDeviceType

func (visitor *Visitor) UserDeviceType() string

func (*Visitor) UserOs

func (visitor *Visitor) UserOs() string

func (*Visitor) UserOsVersion

func (visitor *Visitor) UserOsVersion() string

func (*Visitor) UserReferrer

func (visitor *Visitor) UserReferrer() string

type VisitorInterface

type VisitorInterface interface {
	// From dataobject
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	Path() string
	SetPath(path string) VisitorInterface
	Country() string
	SetCountry(country string) VisitorInterface
	CreatedAt() string
	CreatedAtCarbon() carbon.Carbon
	SetCreatedAt(createdAt string) VisitorInterface
	DeletedAt() string
	SetDeletedAt(deletedAt string) VisitorInterface
	Fingerprint() string
	FingerprintCalculate() string
	SetFingerprint(fingerprint string) VisitorInterface
	ID() string
	SetID(id string) VisitorInterface
	IpAddress() string
	SetIpAddress(ip string) VisitorInterface
	UserAcceptLanguage() string
	SetUserAcceptLanguage(userAcceptLanguage string) VisitorInterface
	UserAcceptEncoding() string
	SetUserAcceptEncoding(userAcceptEncoding string) VisitorInterface
	UserAgent() string
	SetUserAgent(userAgent string) VisitorInterface
	UserBrowser() string
	SetUserBrowser(userBrowser string) VisitorInterface
	UserBrowserVersion() string
	SetUserBrowserVersion(userBrowserVersion string) VisitorInterface
	UserDevice() string
	SetUserDevice(userDevice string) VisitorInterface
	UserDeviceType() string
	SetUserDeviceType(userDeviceType string) VisitorInterface
	UserOs() string
	SetUserOs(userOs string) VisitorInterface
	UserOsVersion() string
	SetUserOsVersion(userOsVersion string) VisitorInterface
	UserReferrer() string
	SetUserReferrer(userReferrer string) VisitorInterface
	// Memo() string
	// SetMemo(memo string) UserInterface
	// Meta(name string) string
	// SetMeta(name string, value string) error
	// Metas() (map[string]string, error)
	// SetMetas(metas map[string]string) error
	// Status() string
	// SetStatus(status string) UserInterface
	UpdatedAt() string
	UpdatedAtCarbon() carbon.Carbon
	SetUpdatedAt(updatedAt string) VisitorInterface
}

func NewVisitor

func NewVisitor() VisitorInterface

func NewVisitorFromExistingData

func NewVisitorFromExistingData(data map[string]string) VisitorInterface

type VisitorQueryOptions

type VisitorQueryOptions struct {
	ID   string
	IDIn []string
	// Status       string
	// StatusIn     []string
	Distinct     string // distinct select column
	Country      string
	CreatedAtGte string
	CreatedAtLte string
	Offset       int
	Limit        int
	SortOrder    string
	OrderBy      string
	CountOnly    bool
	WithDeleted  bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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