Skip to content

Commit dda9dc0

Browse files
authored
Intg-1827 device makes removal (#293)
* add get manufacturers to identity api wrapper * wip * fix more errors * errors fixed, import cycle issue persists * fixed import cycle, linter * fix tests
1 parent 9a29be6 commit dda9dc0

44 files changed

Lines changed: 1234 additions & 5011 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/device-definitions-api/sync_device_definition_search.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515

1616
"github.com/DIMO-Network/device-definitions-api/internal/config"
1717
"github.com/DIMO-Network/device-definitions-api/internal/core/common"
18-
"github.com/DIMO-Network/device-definitions-api/internal/infrastructure/db/models"
1918
"github.com/DIMO-Network/shared/pkg/db"
2019
"github.com/google/subcommands"
2120
"github.com/rs/zerolog"
@@ -72,6 +71,8 @@ func (p *syncDeviceDefinitionSearchCmd) Execute(ctx context.Context, _ *flag.Fla
7271

7372
collectionName := p.settings.SearchServiceIndexName
7473

74+
identity := gateways.NewIdentityAPIService(&p.logger, &p.settings)
75+
7576
if p.createIndex {
7677

7778
_, err := client.Collection(collectionName).Delete(context.Background())
@@ -152,7 +153,7 @@ func (p *syncDeviceDefinitionSearchCmd) Execute(ctx context.Context, _ *flag.Fla
152153

153154
fmt.Printf("Starting processing definitions\n")
154155

155-
makes, err := models.DeviceMakes().All(ctx, pdb.DBS().Reader)
156+
makes, err := identity.GetManufacturers()
156157
if err != nil {
157158
p.logger.Fatal().Err(err).Send()
158159
}
@@ -162,7 +163,7 @@ func (p *syncDeviceDefinitionSearchCmd) Execute(ctx context.Context, _ *flag.Fla
162163
var documents []SearchEntryItem
163164
// iterate over all makes, then query tableland
164165
for _, dm := range makes {
165-
manufacturer, err := onChainSvc.GetManufacturer(dm.NameSlug)
166+
manufacturer, err := onChainSvc.GetManufacturer(stringutils.SlugString(dm.Name))
166167
if err != nil {
167168
p.logger.Fatal().Err(err).Send()
168169
}
@@ -186,7 +187,7 @@ func (p *syncDeviceDefinitionSearchCmd) Execute(ctx context.Context, _ *flag.Fla
186187
}
187188

188189
makeName := dm.Name
189-
makeSlug := dm.NameSlug
190+
makeSlug := stringutils.SlugString(dm.Name)
190191
manufacturerTokenID := manufacturer.TokenID
191192

192193
newDocument := SearchEntryItem{

docs/docs.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -364,39 +364,6 @@ const docTemplate = `{
364364
}
365365
}
366366
},
367-
"/v2/device-definitions/{make}/all": {
368-
"get": {
369-
"description": "gets a device definition",
370-
"consumes": [
371-
"application/json"
372-
],
373-
"produces": [
374-
"application/json"
375-
],
376-
"tags": [
377-
"device-definitions"
378-
],
379-
"summary": "gets all device definitions by Makes, models, and years, from tableland (on-chain records)",
380-
"operationId": "GetDeviceDefinitionV2All",
381-
"parameters": [
382-
{
383-
"type": "string",
384-
"description": "device make name",
385-
"name": "make",
386-
"in": "path",
387-
"required": true
388-
}
389-
],
390-
"responses": {
391-
"200": {
392-
"description": "OK"
393-
},
394-
"500": {
395-
"description": "Internal Server Error"
396-
}
397-
}
398-
}
399-
},
400367
"/vin-profile/{vin}": {
401368
"get": {
402369
"security": [

docs/swagger.json

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -355,39 +355,6 @@
355355
}
356356
}
357357
},
358-
"/v2/device-definitions/{make}/all": {
359-
"get": {
360-
"description": "gets a device definition",
361-
"consumes": [
362-
"application/json"
363-
],
364-
"produces": [
365-
"application/json"
366-
],
367-
"tags": [
368-
"device-definitions"
369-
],
370-
"summary": "gets all device definitions by Makes, models, and years, from tableland (on-chain records)",
371-
"operationId": "GetDeviceDefinitionV2All",
372-
"parameters": [
373-
{
374-
"type": "string",
375-
"description": "device make name",
376-
"name": "make",
377-
"in": "path",
378-
"required": true
379-
}
380-
],
381-
"responses": {
382-
"200": {
383-
"description": "OK"
384-
},
385-
"500": {
386-
"description": "Internal Server Error"
387-
}
388-
}
389-
}
390-
},
391358
"/vin-profile/{vin}": {
392359
"get": {
393360
"security": [

docs/swagger.yaml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -388,29 +388,6 @@ paths:
388388
summary: gets all supported manufacturers for the smartcar external integration
389389
tags:
390390
- device-definitions
391-
/v2/device-definitions/{make}/all:
392-
get:
393-
consumes:
394-
- application/json
395-
description: gets a device definition
396-
operationId: GetDeviceDefinitionV2All
397-
parameters:
398-
- description: device make name
399-
in: path
400-
name: make
401-
required: true
402-
type: string
403-
produces:
404-
- application/json
405-
responses:
406-
"200":
407-
description: OK
408-
"500":
409-
description: Internal Server Error
410-
summary: gets all device definitions by Makes, models, and years, from tableland
411-
(on-chain records)
412-
tags:
413-
- device-definitions
414391
/vin-profile/{vin}:
415392
get:
416393
description: gets VIN profile if we have it.

go.mod

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require (
3131
github.com/tidwall/sjson v1.2.5
3232
github.com/typesense/typesense-go v1.1.0
3333
github.com/volatiletech/null/v8 v8.1.2
34-
github.com/volatiletech/sqlboiler/v4 v4.16.2
34+
github.com/volatiletech/sqlboiler/v4 v4.19.1
3535
github.com/volatiletech/strmangle v0.0.6
3636
go.uber.org/mock v0.4.0
3737
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
@@ -47,6 +47,9 @@ require (
4747
dario.cat/mergo v1.0.0 // indirect
4848
github.com/DIMO-Network/yaml v0.1.0 // indirect
4949
github.com/DataDog/zstd v1.5.2 // indirect
50+
github.com/Masterminds/goutils v1.1.1 // indirect
51+
github.com/Masterminds/semver/v3 v3.1.1 // indirect
52+
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
5053
github.com/MicahParks/keyfunc/v2 v2.1.0 // indirect
5154
github.com/Microsoft/hcsshim v0.12.5 // indirect
5255
github.com/antchfx/xpath v1.3.1 // indirect
@@ -86,13 +89,19 @@ require (
8689
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
8790
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
8891
github.com/gorilla/websocket v1.5.3 // indirect
92+
github.com/hashicorp/hcl v1.0.0 // indirect
8993
github.com/holiman/uint256 v1.3.2 // indirect
94+
github.com/huandu/xstrings v1.3.2 // indirect
95+
github.com/imdario/mergo v0.3.13 // indirect
96+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
9097
github.com/lib/pq v1.10.9 // indirect
9198
github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae // indirect
9299
github.com/mattn/go-colorable v0.1.13 // indirect
93100
github.com/mattn/go-isatty v0.0.20 // indirect
94101
github.com/mattn/go-runewidth v0.0.16 // indirect
95102
github.com/mfridman/interpolate v0.0.2 // indirect
103+
github.com/mitchellh/copystructure v1.2.0 // indirect
104+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
96105
github.com/mmcloughlin/addchain v0.4.0 // indirect
97106
github.com/moby/docker-image-spec v1.3.1 // indirect
98107
github.com/moby/patternmatcher v0.6.0 // indirect
@@ -101,6 +110,8 @@ require (
101110
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
102111
github.com/oapi-codegen/runtime v1.1.1 // indirect
103112
github.com/onsi/gomega v1.19.0 // indirect
113+
github.com/pelletier/go-toml v1.9.5 // indirect
114+
github.com/pelletier/go-toml/v2 v2.0.9 // indirect
104115
github.com/philhofer/fwd v1.1.2 // indirect
105116
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
106117
github.com/prometheus/client_model v0.6.1 // indirect
@@ -111,7 +122,14 @@ require (
111122
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
112123
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
113124
github.com/shoenig/go-m1cpu v0.1.6 // indirect
125+
github.com/shopspring/decimal v1.3.1 // indirect
114126
github.com/sony/gobreaker v1.0.0 // indirect
127+
github.com/spf13/afero v1.9.2 // indirect
128+
github.com/spf13/cobra v1.8.1 // indirect
129+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
130+
github.com/spf13/pflag v1.0.6 // indirect
131+
github.com/spf13/viper v1.12.0 // indirect
132+
github.com/subosito/gotenv v1.4.1 // indirect
115133
github.com/supranational/blst v0.3.14 // indirect
116134
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
117135
github.com/tidwall/match v1.1.1 // indirect
@@ -126,11 +144,13 @@ require (
126144
go.opentelemetry.io/otel/metric v1.29.0 // indirect
127145
go.opentelemetry.io/otel/trace v1.29.0 // indirect
128146
go.uber.org/multierr v1.11.0 // indirect
129-
golang.org/x/crypto v0.37.0 // indirect
147+
golang.org/x/crypto v0.38.0 // indirect
130148
golang.org/x/oauth2 v0.23.0 // indirect
131149
golang.org/x/sync v0.14.0 // indirect
132150
golang.org/x/time v0.9.0 // indirect
133151
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
152+
gopkg.in/ini.v1 v1.67.0 // indirect
153+
gopkg.in/yaml.v2 v2.4.0 // indirect
134154
rsc.io/tmplfunc v0.0.3 // indirect
135155
)
136156

@@ -180,7 +200,7 @@ require (
180200
github.com/volatiletech/randomize v0.0.1 // indirect
181201
golang.org/x/net v0.36.0 // indirect
182202
golang.org/x/sys v0.33.0 // indirect
183-
golang.org/x/text v0.24.0 // indirect
203+
golang.org/x/text v0.25.0 // indirect
184204
golang.org/x/tools v0.29.0 // indirect
185205
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect
186206
gopkg.in/yaml.v3 v3.0.1

0 commit comments

Comments
 (0)