app

package
v0.0.0-...-d941d02 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 28 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AUTHRESHOLD = 3.75

Functions

func CreateToken

func CreateToken(user primitive.ObjectID) string

func GetAuthToken

func GetAuthToken(identityType string, roomName string) (map[string]string, error)

func GetCredentials

func GetCredentials(data string) (username, password string, err error)

func ImageAU

func ImageAU(imgFilename string, outputDirectory string) (map[string]float64, error)

func ImageMetrics

func ImageMetrics(imgFilename string) (map[string]string, error)

func NewResultChannel

func NewResultChannel() chan ResultStruct

func NewSalt

func NewSalt() string

func OpenConnection

func OpenConnection() *mongo.Client

OpenConnection opens connection to mongo server and returns client

func RunCommand

func RunCommand(cmd exec.Cmd) error

func TextSentiment

func TextSentiment(text string) (float64, error)

func VerifyLogin

func VerifyLogin(data, userType string) (*primitive.ObjectID, error)

Types

type APIKeys

type APIKeys struct {
	Algorithmia string
}

func NewAPIKeys

func NewAPIKeys(config string) APIKeys

type Aggregator

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

func AggregatorFromSession

func AggregatorFromSession(session *Session) (*Aggregator, error)

func (*Aggregator) Run

func (agg *Aggregator) Run(clear bool) (map[string]interface{}, error)

type BlankSession

type BlankSession struct {
	CreatedTime int64
	Patient     UserRef
	Provider    UserRef
}

BlankSession for inserting new document with random id rather than our own

type BlankUser

type BlankUser struct {
	Name     string
	Username string
	Password string
}

BlankUser for inserting new document with random id rather than our own

type Entity

type Entity int
const (
	Pat Entity = 0
	Pro Entity = 1
	Ses Entity = 2
)

type FrameMetrics

type FrameMetrics struct {
	Time          int64
	ImageFilename string
	Emotion       map[string]string
	AU            map[string]float64
}

type Grant

type Grant interface {
	ToPayload() map[string]interface{}
	Key() string
}

type IntouchClient

type IntouchClient struct {
	ProCol *mongo.Collection
	PatCol *mongo.Collection
	SesCol *mongo.Collection
}

IntouchClient will add methods for easy transactions with db

func CreateIntouchClient

func CreateIntouchClient(db string, client *mongo.Client) *IntouchClient

CreateIntouchClient uses mongo client to create collections for running queries

func (ic *IntouchClient) AddLink(id primitive.ObjectID, link string) error

func (*IntouchClient) AssociatePatient

func (ic *IntouchClient) AssociatePatient(proID primitive.ObjectID, patID primitive.ObjectID) error

AssociatePatient adds patient to provider's list of patients, as well as provider to target patient's list of providers returns error, nil if ok

func (*IntouchClient) AuthenticateUser

func (ic *IntouchClient) AuthenticateUser(username string, password string, flag Entity) (*primitive.ObjectID, error)

AuthenticateUser checks for a user (specify patient or provider with flag) with given username and password if result found, returns _id else nil and error

func (*IntouchClient) DeleteEntity

func (ic *IntouchClient) DeleteEntity(id primitive.ObjectID, flag Entity) error

DeleteEntity deletes given entity with id (patient, provider, session, etc. based on flag), doesn't check if exists will also update references to deleted entity returns error, nil if ok

func (*IntouchClient) DeleteSessionMetric

func (ic *IntouchClient) DeleteSessionMetric(id primitive.ObjectID, duration time.Duration) error

DeleteSessionMetric deletes a TimeStamp metric based on sentiment string from Session returns error, nil if ok

func (*IntouchClient) DissociatePatient

func (ic *IntouchClient) DissociatePatient(proID primitive.ObjectID, patID primitive.ObjectID) error

DissociatePatient will remove patient and provider from each other's list returns error, nil if ok

func (*IntouchClient) FindLatestSession

func (ic *IntouchClient) FindLatestSession(proUsername string, patUsername string) (*Session, error)

func (*IntouchClient) FindPatient

func (ic *IntouchClient) FindPatient(filter bson.D) (*Patient, error)

FindPatient uses filter to find a patient matching the filter returns nil and err if it fails

func (*IntouchClient) FindPatientByID

func (ic *IntouchClient) FindPatientByID(id primitive.ObjectID) (*Patient, error)

FindPatientByID helper for finding patient by id easily

func (*IntouchClient) FindProvider

func (ic *IntouchClient) FindProvider(filter bson.D) (*Provider, error)

FindProvider uses filter to find a provider matching the filter returns nil and err if it fails

func (*IntouchClient) FindProviderByID

func (ic *IntouchClient) FindProviderByID(id primitive.ObjectID) (*Provider, error)

FindProviderByID helper for finding provider by id easily

func (*IntouchClient) FindSession

func (ic *IntouchClient) FindSession(filter bson.D) (*Session, error)

FindSession uses filter to find a session matching the filter returns nil and err if it fails

func (*IntouchClient) FindSessionByHexString

func (ic *IntouchClient) FindSessionByHexString(hexString string) (*Session, error)

func (*IntouchClient) FindSessionByID

func (ic *IntouchClient) FindSessionByID(id primitive.ObjectID) (*Session, error)

FindSessionByID helper for finding session by id easily

func (ic *IntouchClient) FindSessionByLink(link string) (*Session, error)

FindSessionByLink helper for finding session by link easily

func (*IntouchClient) FindSessionByUserID

func (ic *IntouchClient) FindSessionByUserID(id primitive.ObjectID, flag Entity) (*Session, error)

FindSessionByUserID helper for finding session by user id easily

func (*IntouchClient) FindSessions

func (ic *IntouchClient) FindSessions(filter bson.D) ([]Session, error)

FindSessions uses filter to find sessions matching the filter returns nil and err if it fails

func (*IntouchClient) InsertFrameMetric

func (ic *IntouchClient) InsertFrameMetric(id primitive.ObjectID, metric FrameMetrics) error

InsertSessionMetric adds a TimeStamp metric to a Session returns error, nil if ok

func (*IntouchClient) InsertSession

func (ic *IntouchClient) InsertSession(created int64, patient *UserRef, provider *UserRef) (*primitive.ObjectID, error)

InsertSession inserts a session with link, created time, patient, and provider returns nil id and error if problems arise, else id and nil

func (*IntouchClient) InsertTextMetric

func (ic *IntouchClient) InsertTextMetric(id primitive.ObjectID, metric TextMetrics) error

InsertSessionMetric adds a TimeStamp metric to a Session returns error, nil if ok

func (*IntouchClient) InsertUser

func (ic *IntouchClient) InsertUser(name string, username string, password string, flag Entity) (*primitive.ObjectID, error)

InsertUser inserts a user with name, username, password and checks if username is valid uses flag to decide whether to insert patient or provider returns nil id and error if problems arise, else id and nil

func (*IntouchClient) IsLinkInUse

func (ic *IntouchClient) IsLinkInUse(link string) bool

IsLinkInUse checks if link is already assigned to a session returns true if so, false otherwise

func (*IntouchClient) IsUsernameInUse

func (ic *IntouchClient) IsUsernameInUse(username string) bool

IsUsernameInUse checks if username is already assigned to someone returns true if so, false otherwise

func (*IntouchClient) UpdateSessionSummary

func (ic *IntouchClient) UpdateSessionSummary(session *Session) error

func (*IntouchClient) UpdateUsername

func (ic *IntouchClient) UpdateUsername(id primitive.ObjectID, newusername string, flag Entity) error

UpdateUsername checks if submitted username is in use, if not then updates user of the type set in flag and (patient/provider) and session references to original username. returns error, nil if ok

type LoginHandler

type LoginHandler struct {
	CurrentTokens map[string]UserCache
}

func NewLoginHandler

func NewLoginHandler() LoginHandler

func (LoginHandler) AddLogin

func (lh LoginHandler) AddLogin(user primitive.ObjectID, token, userType string) error

func (LoginHandler) Exists

func (lh LoginHandler) Exists(token string) bool

func (LoginHandler) RemoveLogin

func (lh LoginHandler) RemoveLogin(token string) error

func (LoginHandler) Size

func (lh LoginHandler) Size() int

type MyGrant

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

func NewMyGrant

func NewMyGrant(name string) *MyGrant

func (*MyGrant) Key

func (gr *MyGrant) Key() string

func (*MyGrant) ToPayload

func (gr *MyGrant) ToPayload() map[string]interface{}

type Patient

type Patient struct {
	ID       primitive.ObjectID `bson:"_id"`
	Name     string
	Username string

	Providers []UserRef
	// contains filtered or unexported fields
}

Patient if referenced by Provider or Session then Salt, password, and Patients have no values

func (*Patient) ToRef

func (pat *Patient) ToRef() *UserRef

ToRef converts patient to UserRef

type Provider

type Provider struct {
	ID       primitive.ObjectID `bson:"_id"`
	Name     string
	Username string

	Patients []UserRef
	// contains filtered or unexported fields
}

Provider if referenced by Patient or Session then Salt, password, and Patients have no values

func (*Provider) ToRef

func (pro *Provider) ToRef() *UserRef

ToRef converts provider to UserRef

type ResultStruct

type ResultStruct struct {
	Result interface{}
	Err    error
}

type Session

type Session struct {
	ID           primitive.ObjectID `bson:"_id"`
	Link         string
	CreatedTime  int64
	Patient      UserRef
	Provider     UserRef
	TextMetrics  []TextMetrics  `bson:"text_metrics"`
	ImageMetrics []FrameMetrics `bson:"frame_metrics"`

	Summary map[string]interface{}
}

Session will reference patient and provider by _id, name and username

type TextMetrics

type TextMetrics struct {
	Time      int64
	Text      string
	Sentiment float64
}

type TimestampMetrics

type TimestampMetrics struct {
	Time          string
	Text          string
	Sentiment     float32
	ImageFilename string
	Emotion       map[string]string
	AU            map[string]float64
}

type Twilio

type Twilio struct {
	Key    string `json:"twilioApiKey"`
	Secret string `json:"twilioApiSecret"`
}

type UserCache

type UserCache struct {
	Id       primitive.ObjectID
	UserType string
}

type UserRef

type UserRef struct {
	ID       primitive.ObjectID `bson:"_id"`
	Name     string
	Username string
}

UserRef for appending user as a reference in a different doc user ToRef of Provider or Patient to create UserRef

type WorkerHandler

type WorkerHandler struct {
	Workers chan bool
	// contains filtered or unexported fields
}

func NewWorkerHandler

func NewWorkerHandler(numWorkers int) *WorkerHandler

func (*WorkerHandler) SubmitJob

func (wh *WorkerHandler) SubmitJob(resultChan chan ResultStruct, f func(idx int) (interface{}, error)) error

Jump to

Keyboard shortcuts

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