Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
rename variable
Browse files Browse the repository at this point in the history
Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com>
  • Loading branch information
ianmuchyri authored and dborovcanin committed Mar 14, 2024
1 parent e0d61c5 commit 9e23030
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
5 changes: 2 additions & 3 deletions ui/api/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/csv"
"encoding/json"
"fmt"
"math"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -1952,8 +1951,8 @@ func decodeReadMessagesRequest(_ context.Context, r *http.Request) (interface{},
StringValue: vs,
DataValue: vd,
BoolValue: &vb,
From: from * math.Pow10(ui.PrecisionDiff),
To: to * math.Pow10(ui.PrecisionDiff),
From: from * ui.MilliToNanoConverter,
To: to * ui.MilliToNanoConverter,
Aggregation: aggregation,
Interval: interval,
},
Expand Down
20 changes: 10 additions & 10 deletions ui/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const (
membersActive = "members"
invitationsActive = "invitations"
domainInvitationsActive = "domaininvitations"
PrecisionDiff = 6
)

type LoginStatus string
Expand Down Expand Up @@ -153,11 +152,12 @@ var (
ErrFailedDashboardUpdate = errors.New("failed to update dashboard")
ErrFailedDashboardDelete = errors.New("failed to delete dashboard")

domainRelations = []string{"administrator", "editor", "viewer", "member"}
groupRelations = []string{"administrator", "editor", "viewer"}
statusOptions = []string{"all", "enabled", "disabled"}
uuidPattern = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
intervalPattern = "^([0-9][0-9]*[smhd])$"
domainRelations = []string{"administrator", "editor", "viewer", "member"}
groupRelations = []string{"administrator", "editor", "viewer"}
statusOptions = []string{"all", "enabled", "disabled"}
uuidPattern = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
intervalPattern = "^([0-9][0-9]*[smhd])$"
MilliToNanoConverter = math.Pow10(6)
)

// Service specifies service API.
Expand Down Expand Up @@ -1719,8 +1719,8 @@ func (us *uiService) ReadMessages(s Session, channelID, thingKey string, mpgm sd
return []byte{}, err
}

for _, message := range msg.Messages {
message.Time = message.Time / math.Pow10(-PrecisionDiff)
for i := 0; i < len(msg.Messages); i++ {
msg.Messages[i].Time = msg.Messages[i].Time / MilliToNanoConverter
}

noOfPages := int(math.Ceil(float64(msg.Total) / float64(mpgm.Limit)))
Expand Down Expand Up @@ -1769,8 +1769,8 @@ func (us *uiService) FetchChartData(token string, channelID string, mpgm sdk.Mes
return []byte{}, sdkErr
}

for _, message := range msg.Messages {
message.Time = message.Time / math.Pow10(-PrecisionDiff)
for i := 0; i < len(msg.Messages); i++ {
msg.Messages[i].Time = msg.Messages[i].Time / MilliToNanoConverter
}

data, err := json.Marshal(msg)
Expand Down

0 comments on commit 9e23030

Please sign in to comment.