1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00
wakapi/services/aggregation.go
Ferdinand Mütsch b4c8e6ecb6 Introduce GORM.
2019-05-11 17:49:56 +02:00

30 lines
611 B
Go

package services
import (
"fmt"
"log"
"time"
"github.com/jinzhu/gorm"
"github.com/n1try/wakapi/models"
)
type AggregationService struct {
Db *gorm.DB
HeartbeatService *HeartbeatService
}
func (srv *AggregationService) Aggregate(from time.Time, to time.Time, user *models.User) {
heartbeats, err := srv.HeartbeatService.GetAllFrom(from, user)
if err != nil {
log.Fatal(err)
}
for _, h := range *heartbeats {
fmt.Printf("%+v\n", h)
}
}
func (srv *AggregationService) aggregateBy(*[]models.Heartbeat, models.AggregationType) *models.Aggregation {
return &models.Aggregation{}
}