data

package
v0.0.0-...-f92ab88 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeActivation     = "activation"
	ScopeAuthentication = "authentication"
)

Variables

View Source
var (
	ErrRecordNotFound = errors.New("record not found")
	ErrEditConflict   = errors.New("edit conflict")
	ErrDuplicateEmail = errors.New("duplicate email")
)
View Source
var AnonymousUser = &User{}

Functions

func TableFromReportType

func TableFromReportType(reportType ReportType) string

func ValidateEmail

func ValidateEmail(v *validator.Validator, email string)

func ValidatePaging

func ValidatePaging(v *validator.Validator, p Paging)

func ValidatePasswordPlaintext

func ValidatePasswordPlaintext(v *validator.Validator, password string)

func ValidateUser

func ValidateUser(v *validator.Validator, user *User)

Types

type Economic

type Economic struct {
	Date  time.Time       `db:"time" json:"date"`
	Value decimal.Decimal `db:"value" json:"value"`
}

type EconomicRepository

type EconomicRepository interface {
	LatestWithPercentChange(ctx context.Context, table string) (*EconomicWithChange, error)
	GetIntervalWithPercentChange(ctx context.Context, table string, years int, paging Paging) (*EconomicWithChangeResult, error)
	GetStats(ctx context.Context, table string, years int, timeBucketDays int, paging Paging) (*EconomicStatsResult, error)
	GetAll(ctx context.Context, table string) (*[]Economic, error)
	Insert(ctx context.Context, table string, data *Economic) error
	InsertMany(ctx context.Context, table string, data *[]Economic) error
}

type EconomicStats

type EconomicStats struct {
	StartDate time.Time       `db:"start_date" json:"from"`
	EndDate   time.Time       `db:"end_date" json:"to"`
	Stddev    decimal.Decimal `db:"stddev" json:"stddev"`
	Mean      decimal.Decimal `db:"mean" json:"mean"`
	Min       decimal.Decimal `db:"min" json:"min"`
	Max       decimal.Decimal `db:"max" json:"max"`
}

type EconomicStatsResult

type EconomicStatsResult struct {
	Data *[]EconomicStats
	Meta *Metadata
}

type EconomicWithChange

type EconomicWithChange struct {
	Date   time.Time       `db:"time" json:"date"`
	Value  decimal.Decimal `db:"value" json:"value"`
	Change decimal.Decimal `db:"percentage_change" json:"change"`
}

type EconomicWithChangeResult

type EconomicWithChangeResult struct {
	Data *[]EconomicWithChange
	Meta *Metadata
}

type Extras

type Extras map[string]interface{}

func (*Extras) Scan

func (e *Extras) Scan(value interface{}) error

func (Extras) Value

func (e Extras) Value() (driver.Value, error)

type Metadata

type Metadata struct {
	CurrentPage  int                    `json:"current_page"`
	PageSize     int                    `json:"page_size"`
	FirstPage    int                    `json:"first_page"`
	LastPage     int                    `json:"last_page"`
	TotalRecords int                    `json:"total_records"`
	Props        map[string]interface{} `json:"props"`
}

func CalculateMetadata

func CalculateMetadata(totalRecords, page, pageSize int) Metadata

type Paging

type Paging struct {
	Page     int
	PageSize int
}

func (*Paging) Limit

func (p *Paging) Limit() int

func (*Paging) Offset

func (p *Paging) Offset() int

type Permissions

type Permissions []string

func (*Permissions) Included

func (p *Permissions) Included(code string) bool

type PermissionsRepository

type PermissionsRepository interface {
	GetAllForUser(userId int64) (Permissions, error)
	AddForUser(userId int64, codes ...string) error
}

type Report

type Report struct {
	Id                      int64     `db:"id" json:"id"`
	Slug                    string    `db:"slug" json:"slug"`
	DisplayName             string    `db:"display_name" json:"displayName"`
	Description             string    `db:"description" json:"description"`
	Image                   string    `db:"image" json:"image"`
	LastPullDate            time.Time `db:"last_data_pull" json:"lastPullDate"`
	InitialSyncDelayMinutes int       `db:"initial_sync_delay_minutes" json:"initialSyncDelayMinutes"`
	Extras                  Extras    `json:"extras"`
}

type ReportRepository

type ReportRepository interface {
	GetAllReports(ctx context.Context) ([]*Report, error)
	UpdateReportLastPullDate(ctx context.Context, slug string) error
	GetReportBySlug(ctx context.Context, slug string) (*Report, error)
	GetReports(ctx context.Context) (*[]Report, error)
}

type ReportType

type ReportType int8
const (
	CPI ReportType = iota
	ConsumerSentiment
	RetailSales
	TreasuryYieldThreeMonth
	TreasuryYieldTwoYear
	TreasuryYieldFiveYear
	TreasuryYieldSevenYear
	TreasuryYieldTenYear
	TreasuryYieldThirtyYear
	RealGDP
	RealGdpPerCapita
	FederalFundsRate
	DurableGoodsOrders
	Unemployment
	NonfarmPayroll
	Inflation
	InflationExpectation
	Unknown
)

func ReportTypeTreasuryYieldMaturity

func ReportTypeTreasuryYieldMaturity(maturity string) ReportType

func (ReportType) String

func (r ReportType) String() string

func (ReportType) ToTable

func (r ReportType) ToTable() string

type Summary

type Summary struct {
	Name       string                 `json:"name"`
	LastUpdate time.Time              `json:"lastUpdate"`
	Value      decimal.Decimal        `json:"value"`
	Change     decimal.Decimal        `json:"change"`
	Slug       string                 `json:"slug"`
	Extras     map[string]interface{} `json:"extras"`
}

type Token

type Token struct {
	Plaintext string    `json:"token"`
	Hash      []byte    `json:"-" db:"hash"`
	UserId    int64     `json:"-" db:"user_id"`
	Expiry    time.Time `json:"expiry" db:"expiry"`
	Scope     string    `json:"-" db:"scope"`
}

func GenerateToken

func GenerateToken(ctx context.Context, userId int64, ttl time.Duration, scope string) (*Token, error)

type TokenRepository

type TokenRepository interface {
	Insert(ctx context.Context, token *Token) error
	DeleteAllForUser(ctx context.Context, userId int64, scope string) error
}

type TreasuryMaturity

type TreasuryMaturity string

func MaturityFromReportType

func MaturityFromReportType(report ReportType) TreasuryMaturity

type User

type User struct {
	ID        int64     `json:"id" db:"id"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	Name      string    `json:"name" db:"name"`
	Email     string    `json:"email" db:"email"`
	Password  password  `json:"-" db:"password_hash"`
	Activated bool      `json:"activated" db:"activated"`
	Version   int       `json:"-" db:"version"`
}

type UserRepository

type UserRepository interface {
	Insert(ctx context.Context, user *User) error
	Update(ctx context.Context, user *User) error
	GetByEmail(ctx context.Context, email string) (*User, error)
	GetFromToken(ctx context.Context, tokenScope, tokenplaintext string) (*User, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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