Skip to content

Commit 866ca12

Browse files
committed
fixes to the Aviato plugin
1 parent 389c9a9 commit 866ca12

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

engine/plugins/api/aviato/company_enrich.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (ce *companyEnrich) query(e *et.Event, ident *dbt.Entity, apikey []string)
9393
orgent := ce.lookup(e, ident, time.Time{})
9494
if orgent == nil {
9595
msg := fmt.Sprintf("failed to find the Organization asset for %s", oamid.UniqueID)
96-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
96+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
9797
return nil, nil
9898
}
9999

@@ -110,19 +110,19 @@ func (ce *companyEnrich) query(e *et.Event, ident *dbt.Entity, apikey []string)
110110
resp, err := http.RequestWebPage(ctx, &http.Request{URL: u, Header: headers})
111111
if err != nil {
112112
msg := fmt.Sprintf("failed to obtain the company enrich result for %s: %s", oamid.ID, err)
113-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
113+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
114114
continue
115115
} else if resp.StatusCode != 200 {
116116
msg := fmt.Sprintf("failed to obtain the company enrich result for %s: %s", oamid.ID, resp.Status)
117-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
117+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
118118
continue
119119
} else if resp.Body == "" {
120120
msg := fmt.Sprintf("failed to obtain the company enrich result for %s: empty body", oamid.ID)
121-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
121+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
122122
continue
123123
} else if strings.Contains(resp.Body, "error") {
124124
msg := fmt.Sprintf("failed to obtain the company enrich result for %s: %s", oamid.ID, resp.Body)
125-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
125+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
126126
continue
127127
}
128128

@@ -131,7 +131,7 @@ func (ce *companyEnrich) query(e *et.Event, ident *dbt.Entity, apikey []string)
131131
enrich = &result
132132
} else {
133133
msg := fmt.Sprintf("failed to unmarshal the company enrich result for %s: %s", oamid.ID, err)
134-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
134+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
135135
}
136136
break
137137
}
@@ -165,7 +165,7 @@ func (ce *companyEnrich) store(e *et.Event, orgent *dbt.Entity, data *companyEnr
165165
ident, err := e.Session.Cache().CreateAsset(oamid)
166166
if err != nil || ident == nil {
167167
msg := fmt.Sprintf("failed to create the Identifier asset for %s: %s", o.LegalName, err)
168-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
168+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
169169
return
170170
}
171171

@@ -175,22 +175,22 @@ func (ce *companyEnrich) store(e *et.Event, orgent *dbt.Entity, data *companyEnr
175175
})
176176
if err != nil {
177177
msg := fmt.Sprintf("failed to create the SourceProperty for %s: %s", o.LegalName, err)
178-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
178+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
179179
return
180180
}
181181

182182
err = ce.plugin.createRelation(e.Session, orgent, general.SimpleRelation{Name: "id"}, ident, ce.plugin.source.Confidence)
183183
if err != nil {
184184
msg := fmt.Sprintf("failed to create the relation for %s: %s", o.LegalName, err)
185-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
185+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
186186
return
187187
}
188188
}
189189
// update entity
190190
_, err := e.Session.Cache().CreateEntity(orgent)
191191
if err != nil {
192192
msg := fmt.Sprintf("failed to update the Organization asset for %s: %s", o.Name, err)
193-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
193+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ce.plugin.name, "handler", ce.name))
194194
return
195195
}
196196
}

engine/plugins/api/aviato/employees.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (ae *employees) query(e *et.Event, ident *dbt.Entity, apikey []string) (*db
116116
orgent := ae.getAssociatedOrg(e, ident)
117117
if orgent == nil {
118118
msg := fmt.Sprintf("failed to find the Organization asset for %s", oamid.UniqueID)
119-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
119+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
120120
return nil, []*dbt.Entity{}
121121
}
122122

@@ -138,26 +138,26 @@ loop:
138138
resp, err := http.RequestWebPage(ctx, &http.Request{URL: u, Header: headers})
139139
if err != nil {
140140
msg := fmt.Sprintf("failed to obtain the employees for %s: %s", oamid.ID, err)
141-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
141+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
142142
continue
143143
} else if resp.StatusCode != 200 {
144144
msg := fmt.Sprintf("failed to obtain the employees for %s: %s", oamid.ID, resp.Status)
145-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
145+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
146146
continue
147147
} else if resp.Body == "" {
148148
msg := fmt.Sprintf("failed to obtain the employees for %s: empty body", oamid.ID)
149-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
149+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
150150
continue
151151
} else if strings.Contains(resp.Body, "error") {
152152
msg := fmt.Sprintf("failed to obtain the employees for %s: %s", oamid.ID, resp.Body)
153-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
153+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
154154
continue
155155
}
156156

157157
var result employeesResult
158158
if err := json.Unmarshal([]byte(resp.Body), &result); err != nil {
159159
msg := fmt.Sprintf("failed to unmarshal the employees for %s: %s", oamid.ID, err)
160-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
160+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
161161
break loop
162162
} else if len(result.Employees) == 0 {
163163
break loop
@@ -212,7 +212,7 @@ func (ae *employees) store(e *et.Event, ident, orgent *dbt.Entity, employlist []
212212
personent, err := e.Session.Cache().CreateAsset(p)
213213
if err != nil {
214214
msg := fmt.Sprintf("failed to create the Person asset for %s: %s", p.FullName, err)
215-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
215+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
216216
continue
217217
}
218218

@@ -222,7 +222,7 @@ func (ae *employees) store(e *et.Event, ident, orgent *dbt.Entity, employlist []
222222
})
223223
if err != nil {
224224
msg := fmt.Sprintf("failed to create the Person asset source property for %s: %s", p.FullName, err)
225-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
225+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
226226
continue
227227
}
228228

@@ -231,7 +231,7 @@ func (ae *employees) store(e *et.Event, ident, orgent *dbt.Entity, employlist []
231231
employents = append(employents, personent)
232232
} else {
233233
msg := fmt.Sprintf("failed to create the member relation for %s: %s", p.FullName, err)
234-
e.Session.Log().Error("msg", msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
234+
e.Session.Log().Error(msg, slog.Group("plugin", "name", ae.plugin.name, "handler", ae.name))
235235
}
236236
}
237237

engine/plugins/api/aviato/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ type companyEnrichResult struct {
137137
IndustryList []string `json:"industryList"`
138138
BusinessModelList []string `json:"businessModelList"`
139139
ProductList []struct {
140-
ProductName string `json:"productName"`
141-
Tagline string `json:"tagline"`
142-
CreatedAt string `json:"createdAt"`
140+
ProductName string `json:"productName"`
141+
Tagline string `json:"tagline"`
142+
//CreatedAt string `json:"createdAt"` documentation is not clear
143143
ImageID string `json:"imageID"`
144144
ProductURL string `json:"productURL"`
145145
ProductHuntURL string `json:"producthuntURL"`
@@ -196,7 +196,7 @@ type companyEnrichResult struct {
196196
DocumentURL string `json:"documentUrl"`
197197
LatestFilingDate string `json:"latestFilingDate"`
198198
} `json:"ownedPatents"`
199-
GovernmentAwards struct {
199+
GovernmentAwards []struct {
200200
AwardID string `json:"awardId"`
201201
AwardType string `json:"awardType"`
202202
AwardAmount float64 `json:"awardAmount"`

0 commit comments

Comments
 (0)