feat(scraper): bound article enrichment diagnostics (#40)
This commit is contained in:
@ -30,7 +30,8 @@ func (b *Bloomberg) EnrichWithCredentials(ctx context.Context, username, passwor
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
URLs []string `json:"urls"`
|
||||
}{username, password, urls})
|
||||
Measure bool `json:"measure_fetches,omitempty"`
|
||||
}{username, password, urls, scraper.FetchMetricsEnabled(ctx)})
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, b.scraperURL+"/bloomberg/enrich", bytes.NewReader(payload))
|
||||
if err != nil {
|
||||
return nil, errors.New("bloomberg: enrichment request failed")
|
||||
@ -53,7 +54,8 @@ func (b *Bloomberg) EnrichWithCredentials(ctx context.Context, username, passwor
|
||||
return nil, errors.New("bloomberg: enrichment response too large")
|
||||
}
|
||||
var result struct {
|
||||
Articles []struct {
|
||||
FetchMetrics *scraper.FetchMetrics `json:"fetch_metrics"`
|
||||
Articles []struct {
|
||||
ContentState string `json:"content_state"`
|
||||
URL string `json:"url"`
|
||||
Content string `json:"content"`
|
||||
@ -89,5 +91,8 @@ func (b *Bloomberg) EnrichWithCredentials(ctx context.Context, username, passwor
|
||||
}
|
||||
}
|
||||
}
|
||||
if result.FetchMetrics != nil {
|
||||
scraper.MergeFetchMetrics(ctx, *result.FetchMetrics, len(out))
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user