db

package
v0.0.0-...-e363bdf Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	URI      = "mongodb://localhost:27017"
	Database = "tasks"

	Collection = "taskCollection"
)
View Source
const (
	ContainerName = "utaskmongo"
)
View Source
const (
	GrpcPort = ":9070"
)

Variables

This section is empty.

Functions

func CountNumUtasksPerDay

func CountNumUtasksPerDay(taskTraces []TaskTrace) (map[string]int, []string)

CountNumUtasksPerDay count the number of utasks registered per date in date order old -> new

func CountUtaskPerProject

func CountUtaskPerProject(taskTraces []TaskTrace) map[string]int

CountUtaskPerProject count the number of entries per project

func DeleteAllTasks

func DeleteAllTasks() error

func GrpcServer

func GrpcServer()

GrpcServer gRPC server for the db contents

func QueryAllTasks

func QueryAllTasks() (*[]TaskTrace, error)

QueryAllTasks return all task traces by first searching in db and then the file

func SaveTask

func SaveTask(c <-chan TaskTrace)

func StartMux

func StartMux(c chan<- TaskTrace)

Types

type MongoConn

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

MongoConn db connection

func NewMongoConn

func NewMongoConn(URI string, database string, colName string) (*MongoConn, error)

NewMongoConn if container is not running, restart it or create a new one start connection with the container

func (*MongoConn) DeleteAll

func (db *MongoConn) DeleteAll() error

func (*MongoConn) Disconnect

func (db *MongoConn) Disconnect() error

Disconnect from db connection

func (*MongoConn) GetAllDocuments

func (db *MongoConn) GetAllDocuments() ([]map[string]interface{}, error)

func (*MongoConn) InsertNewDocument

func (db *MongoConn) InsertNewDocument(intf interface{}) error

type PlotData

type PlotData struct {
	Labels []string
	Data   []int
}

type Task

type Task struct {
	ProjectName string // project that the task belongs to
	TaskName    string //
	Details     string // additional info regarding the task
}

Task contains task details that are fetched from the the socket interface and registered to the db as document

type TaskTrace

type TaskTrace struct {
	SDate string // date for the task
	STime string // time stamp for the task
	T     Task   // Task details
}

TaskTrace is the document that will be saved to the collection

func SortTaskList

func SortTaskList(taskTraces []TaskTrace) []TaskTrace

SortTaskList sort task list with project name

type UTaskServer

type UTaskServer struct{}

func (UTaskServer) GetDailyTaskCount

GetDailyTaskCount return number of tasks per day

func (UTaskServer) GetPlot

func (UTaskServer) GetProjectTaskCount

GetProjectTaskCount returns the number of utasks per project

func (UTaskServer) GetTasks

GetTasks streams all tasks in db back to the client

func (UTaskServer) Ping

type UTaskdb

type UTaskdb struct {
	TaskFile        string // file to save the tasks
	MongoURI        string
	MongoDatabase   string
	MongoCollection string
}

UTaskdb contains csv file or db details for saving utasks

func (*UTaskdb) SaveTaskTrace

func (utaskdb *UTaskdb) SaveTaskTrace(t *TaskTrace) error

SaveTaskTrace is the main entry point for saving cfg details to db or text file return errors if any occurs while saving the task details tries to save to both db and text

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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