Skip to content

Commit

Permalink
Add deviceId to system state API
Browse files Browse the repository at this point in the history
  • Loading branch information
danesparza committed Jul 28, 2017
1 parent bcbef33 commit 32cb39e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions api/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type CurrentState struct {
ServerStartTime time.Time `json:"starttime"`
ApplicationVersion string `json:"appversion"`
DeviceRunning bool `json:"devicerunning"`
DeviceID string `json:"deviceId"`
}

// GetCurrentState gets the current running state of the application
Expand All @@ -22,13 +23,19 @@ func GetCurrentState(rw http.ResponseWriter, req *http.Request) {
// Find out if the device is currently running:
activityDB := data.ActivityDB{
Database: viper.GetString("datastore.activity")}
response, _ := activityDB.GetLatestActivity()
latestActivity, _ := activityDB.GetLatestActivity()

// Get the current datastore:
// Get config information:
configDB := data.ConfigDB{
Database: viper.GetString("datastore.config")}
deviceID, _ := configDB.Get("deviceID")

// Create a CurrentState type:
currentState := CurrentState{
ServerStartTime: ApplicationStartTime,
DeviceRunning: response.Type == data.ApplianceRunning,
DeviceRunning: latestActivity.Type == data.ApplianceRunning,
ApplicationVersion: BuildVersion,
DeviceID: deviceID.Value,
}

// Serialize to JSON & return the response:
Expand Down

0 comments on commit 32cb39e

Please sign in to comment.