Skip to content

Commit

Permalink
add todo comments, make method not exported
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesReate committed Nov 16, 2023
1 parent 4e65c4b commit 96e0283
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/controllers/device_config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (d *DeviceConfigController) GetDBCFileByTemplateName(c *fiber.Ctx) error {

}

func (d *DeviceConfigController) GetConfigURLs(c *fiber.Ctx, ud *pb.UserDevice) error {
func (d *DeviceConfigController) getConfigURLs(c *fiber.Ctx, ud *pb.UserDevice) error {
baseURL := d.settings.DeploymentURL

switch ud.CANProtocol {
Expand Down Expand Up @@ -277,6 +277,8 @@ func (d *DeviceConfigController) GetConfigURLs(c *fiber.Ctx, ud *pb.UserDevice)
).All(context.Background(), d.db)

if err != nil {
// todo what if err is sql.ErrNoRows - eg. nothing found? we would probably want to return the first default template
// todo - this should just return the wrapped error and let the api.ErrorHandler deal with how to return the error
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": fmt.Sprintf("Failed to query templates for protocol: %s and powertrain: %s", ud.CANProtocol, ud.PowerTrainType)})
}

Expand All @@ -294,6 +296,7 @@ func (d *DeviceConfigController) GetConfigURLs(c *fiber.Ctx, ud *pb.UserDevice)
}
}
if matchedTemplate == nil {
// todo - what if templates length is 0? maybe handle this further above
matchedTemplate = templates[0]
}

Expand Down Expand Up @@ -350,7 +353,7 @@ func (d *DeviceConfigController) GetConfigURLsFromVIN(c *fiber.Ctx) error {
// todo: get powertrain type from definition response and include in ud.PowerTrainType
}

return d.GetConfigURLs(c, ud)
return d.getConfigURLs(c, ud)
}

// GetConfigURLsFromEthAddr godoc
Expand All @@ -368,7 +371,7 @@ func (d *DeviceConfigController) GetConfigURLsFromEthAddr(c *fiber.Ctx) error {
if err != nil {
return c.Status(fiber.StatusNotFound).JSON(fiber.Map{"error": fmt.Sprintf("no connected user device found for EthAddr: %s", ethAddr)})
}
return d.GetConfigURLs(c, ud)
return d.getConfigURLs(c, ud)
}

func padByteArray(input []byte, targetLength int) []byte {
Expand Down
1 change: 1 addition & 0 deletions internal/core/queries/get_pid_config_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package queries
import (
"context"
"fmt"

"github.com/DIMO-Network/shared/db"
"github.com/DIMO-Network/vehicle-signal-decoding/internal/infrastructure/db/models"
grpc "github.com/DIMO-Network/vehicle-signal-decoding/pkg/grpc"
Expand Down

0 comments on commit 96e0283

Please sign in to comment.