A few tweaks
This commit is contained in:
31
app.go
31
app.go
@@ -2,8 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.cems.dev/cdricms/bdooc/proto"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
@@ -52,13 +50,6 @@ func (a *App) GetEmployees(path string, limit, page uint, column, query *string)
|
||||
return a.employees.Employees[page*limit : page*limit+limit], nil
|
||||
}
|
||||
|
||||
func (a *App) SaveData(data []uint8, filename string) {
|
||||
err := proto.SaveToFile(data, filename)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) GetProtoPath() string {
|
||||
return a.OpenPath([]runtime.FileFilter{{
|
||||
DisplayName: "Proto binary file",
|
||||
@@ -78,8 +69,22 @@ func (a *App) OpenPath(filters []runtime.FileFilter) string {
|
||||
return path
|
||||
}
|
||||
|
||||
func (a *App) IsPathValid(path string) bool {
|
||||
_, err := os.Stat(path)
|
||||
fmt.Println(path)
|
||||
return !os.IsNotExist(err)
|
||||
type FunctionAgg string
|
||||
|
||||
const (
|
||||
AVG = FunctionAgg("AVG")
|
||||
SUM = FunctionAgg("SUM")
|
||||
)
|
||||
|
||||
func (a *App) AggregateByColumn(groupBy proto.EmployeeField, on proto.EmployeeField, function FunctionAgg) map[string]float64 {
|
||||
return proto.AggregateByColumn(a.employees, proto.EmployeeField(proto.SnakeCaseToPascalCase(string(groupBy))), func(ep proto.EmployeePList) float64 {
|
||||
switch function {
|
||||
case AVG:
|
||||
return proto.Average(ep, proto.EmployeeField(proto.SnakeCaseToPascalCase(string(on))))
|
||||
case SUM:
|
||||
return proto.Sum(ep, proto.EmployeeField(proto.SnakeCaseToPascalCase(string(on))))
|
||||
}
|
||||
|
||||
return 0.0
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user