models

package
v0.0.0-...-32823bc Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

todo: generate models through scaffolds

todo: generate models through scaffolds

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchBatches

func FetchBatches(user_id gocql.UUID, limit int) *[]map[string]interface{}

Retrieves batches associated to a user

func FetchLogs

func FetchLogs(batch_id gocql.UUID, page gocql.UUID, order_by string, limit int) *[]map[string]interface{}

Fetch array of logs

func GetWeekStats

func GetWeekStats(user_id gocql.UUID) *[]map[string]interface{}

Returns stats of a week

Types

type Batch

type Batch struct {
	Batch_id gocql.UUID
	User_id  gocql.UUID

	Status string

	Options    map[string]string
	Created_at time.Time
	// contains filtered or unexported fields
}

func NewBatch

func NewBatch() *Batch

set UUID v1

func (*Batch) Create

func (b *Batch) Create(data map[string]interface{}) (bool, error)

Create a new User, check user.Exists() before trying to create a new one

func (*Batch) Exists

func (b *Batch) Exists() (bool, error)

Check if a Batch exists, if then populate the model

func (*Batch) GetId

func (b *Batch) GetId() string

func (*Batch) GetMap

func (b *Batch) GetMap() map[string]interface{}

Return data in format of map for json response

func (*Batch) Populate

func (b *Batch) Populate(data map[string]interface{}) *Batch

Queried Batch to Batch struct

func (*Batch) Update

func (b *Batch) Update(data map[string]interface{}) (bool, error)

type GithubUser

type GithubUser struct {
	UUID         string `json:uuid`
	Avatar_Url   string `json:avatar_url`
	Name         string `json:name`
	Company      string `json:company`
	Location     string `json:location`
	Email        string `json:email`
	Access_Token string `json:access_token`
	Api_key      string `json:api_key`
}

these data points can be extended further that's why kept seperate from UserRedis struct

type Log

type Log struct {
	Log_id   gocql.UUID
	Batch_id gocql.UUID
	User_id  gocql.UUID
	// Client_key string // todo: make use of client_id
	Email      string
	State      string
	Status     map[string]bool // a map of service providers state
	LastUpdate time.Time
	Created_at time.Time
}

func NewLog

func NewLog() *Log

set UUID v1

func (*Log) Create

func (l *Log) Create(data map[string]interface{}) (bool, error)

Creates a new Log doc

func (*Log) Exists

func (l *Log) Exists() (bool, error)

Check if a Batch exists, if then populate the model

func (*Log) GetId

func (l *Log) GetId() string

func (*Log) GetMap

func (l *Log) GetMap() map[string]interface{}

Return data in format of map for json response

func (*Log) Populate

func (l *Log) Populate(data map[string]interface{}) *Log

Queried Batch to Batch struct

func (*Log) Update

func (l *Log) Update(data map[string]interface{}) (bool, error)

type Stat

type Stat struct {
	Failed  int64
	Success int64
	Queued  int64
	User_Id gocql.UUID
	Date    time.Time
}

func NewStat

func NewStat(user_id gocql.UUID) *Stat

func (*Stat) Exists

func (s *Stat) Exists() bool

func (*Stat) Populate

func (s *Stat) Populate(data map[string]interface{})

func (*Stat) Update

func (s *Stat) Update(options []string) bool

type User

type User struct {
	User_Id gocql.UUID
	Email   string
	Name    string
	Api_Key string
	// Client_id string : todo: add a client id and let user have multi api_keys
	Location   string
	User_Type  int
	Auth_Token string
	Company    string
	Created_at time.Time
}

func (*User) Create

func (u *User) Create(data map[string]interface{}) (bool, error)

Create a new User, check user.Exists() before trying to create a new one

func (*User) Exists

func (u *User) Exists() (bool, error)

Check if a User exists, if then populate the model

func (*User) GetId

func (u *User) GetId() string

func (*User) GetUUID

func (u *User) GetUUID() gocql.UUID

Returns UUID in orignal format

func (*User) New

func (u *User) New() *User

set UUID v1

func (*User) Populate

func (u *User) Populate(data map[string]interface{}) *User

Queried User to User struct

func (*User) Update

func (u *User) Update(data map[string]interface{}) (bool, error)

type UserRedis

type UserRedis struct {
	UUID       string `json:uuid`
	Name       string `json:name`
	Email      string `json:email`
	Avatar_Url string `json:avatar_url`
	Api_key    string `json:api_key`
	Company    string `json:company`
	Location   string `json:location`
}

Jump to

Keyboard shortcuts

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