removing error not required
This commit is contained in:
parent
8b116f51a6
commit
8036c9840b
@ -52,11 +52,11 @@ func (t *TH7Adapter) GetChannel(id int) (core.Channel, error) {
|
|||||||
return core.Channel{}, errors.New("specified channel not configured")
|
return core.Channel{}, errors.New("specified channel not configured")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TH7Adapter) GetChannels() ([]core.Channel, error) {
|
func (t *TH7Adapter) GetChannels() []core.Channel {
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
defer t.mu.Unlock()
|
defer t.mu.Unlock()
|
||||||
|
|
||||||
return t.data, nil
|
return t.data
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TH7Adapter) GetVref() float64 {
|
func (t *TH7Adapter) GetVref() float64 {
|
||||||
|
@ -11,14 +11,11 @@ func startLoggingProcess(db ports.DBPort, core ports.CorePort, dur time.Duration
|
|||||||
// wait 10 seconds to not log start up values that can be noisy
|
// wait 10 seconds to not log start up values that can be noisy
|
||||||
time.Sleep(10 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
|
|
||||||
for true {
|
for {
|
||||||
|
|
||||||
val, err := core.GetChannels()
|
val := core.GetChannels()
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Error encountered while getting values: %v\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = db.Save(val)
|
err := db.Save(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error encountered while saving values: %v\n", err)
|
fmt.Printf("Error encountered while saving values: %v\n", err)
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@ func NewSQLite3Adapter(dbInfo map[string]interface{}) (*SQLite3Adapter, error) {
|
|||||||
|
|
||||||
func (ad *SQLite3Adapter) Close() {
|
func (ad *SQLite3Adapter) Close() {
|
||||||
ad.db.Close()
|
ad.db.Close()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ad *SQLite3Adapter) Save([]core.Channel) error {
|
func (ad *SQLite3Adapter) Save([]core.Channel) error {
|
||||||
|
@ -4,7 +4,7 @@ import "th7/data/core"
|
|||||||
|
|
||||||
type CorePort interface {
|
type CorePort interface {
|
||||||
GetChannel(int) (core.Channel, error)
|
GetChannel(int) (core.Channel, error)
|
||||||
GetChannels() ([]core.Channel, error)
|
GetChannels() []core.Channel
|
||||||
GetVref() float64
|
GetVref() float64
|
||||||
GetVadj() float64
|
GetVadj() float64
|
||||||
GetPivdd() float64
|
GetPivdd() float64
|
||||||
|
@ -17,15 +17,8 @@ type GinAdapter struct {
|
|||||||
func (g GinAdapter) registerEndpoints() {
|
func (g GinAdapter) registerEndpoints() {
|
||||||
|
|
||||||
g.router.GET("/channels", func(c *gin.Context) {
|
g.router.GET("/channels", func(c *gin.Context) {
|
||||||
channels, err := g.corePort.GetChannels()
|
channels := g.corePort.GetChannels()
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
|
||||||
"error": err,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
c.JSON(http.StatusOK, channels)
|
c.JSON(http.StatusOK, channels)
|
||||||
}
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
g.router.GET("/channel/:id", func(c *gin.Context) {
|
g.router.GET("/channel/:id", func(c *gin.Context) {
|
||||||
|
Loading…
Reference in New Issue
Block a user