Skip to content

Commit b60c0de

Browse files
committed
tweaks to seerch sync code
1 parent 70873e3 commit b60c0de

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

cmd/device-definitions-api/sync_device_definition_search.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ func (p *syncDeviceDefinitionSearchCmd) Execute(ctx context.Context, _ *flag.Fla
207207
documents = append(documents, newDocument)
208208
}
209209
definitions = nil // will this help rambo the gc?
210+
fmt.Printf("loaded %d definitions from %s \n", len(documents), manufacturer.Name)
210211
}
211212

212213
err = uploadWithAPI(client, documents, p.settings.SearchServiceIndexName)

internal/infrastructure/gateways/device_definition_on_chain_service.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (e *deviceDefinitionOnChainService) GetDeviceDefinitions(ctx context.Contex
226226
return modelTableland, nil
227227
}
228228

229-
// QueryDefinitionsCustom queries tableland definitions oem table based on manuf ID. Always page size of 50, but you can alter the page index
229+
// QueryDefinitionsCustom queries tableland definitions oem table based on manuf ID. Always page size of 500, but you can alter the page index
230230
func (e *deviceDefinitionOnChainService) QueryDefinitionsCustom(ctx context.Context, manufacturerID int, whereClause string, pageIndex int) ([]models2.DeviceDefinitionTablelandModel, error) {
231231
if manufacturerID == 0 {
232232
return nil, fmt.Errorf("manufacturerID cannot be 0")
@@ -237,8 +237,11 @@ func (e *deviceDefinitionOnChainService) QueryDefinitionsCustom(ctx context.Cont
237237
if err != nil {
238238
return nil, err
239239
}
240+
if tableName == "" {
241+
return nil, fmt.Errorf("tableName cannot be empty for manufacturer token id %d", manufacturerID)
242+
}
240243

241-
statement := fmt.Sprintf("SELECT * FROM %s %s LIMIT %d OFFSET %d", tableName, whereClause, 50, pageIndex)
244+
statement := fmt.Sprintf("SELECT * FROM %s %s LIMIT %d OFFSET %d", tableName, whereClause, 500, pageIndex)
242245

243246
queryParams := map[string]string{
244247
"statement": statement,

0 commit comments

Comments
 (0)