twitterchiver/related_fetcher: move the fetch token counter to right before we do the fetch
This commit is contained in:
parent
d6cfb865ad
commit
0da26f3e42
1 changed files with 5 additions and 4 deletions
|
@ -333,10 +333,6 @@ func relatedFetchTick(ctx context.Context, cfg WorkerConfig) error {
|
|||
httpClient := cfg.OAuthConfig.Client(ctx, oauth1.NewToken(accessToken, accessSecret))
|
||||
|
||||
for _, tid := range tweetIDsToFetch {
|
||||
if _, ok := <-fetchLimited; !ok {
|
||||
log.Printf("[%v:%d] Out of fetch tokens", cfg.Name, t.ID)
|
||||
break
|
||||
}
|
||||
// Check if we already have tid.
|
||||
log.Printf("[%v:%d] Fetching %d", cfg.Name, t.ID, tid)
|
||||
|
||||
|
@ -350,6 +346,11 @@ func relatedFetchTick(ctx context.Context, cfg WorkerConfig) error {
|
|||
continue
|
||||
}
|
||||
|
||||
if _, ok := <-fetchLimited; !ok {
|
||||
log.Printf("[%v:%d] Out of fetch tokens", cfg.Name, t.ID)
|
||||
break
|
||||
}
|
||||
|
||||
// We don't have it already; let's fetch it from ze Twitterz.
|
||||
req, err := http.NewRequest("GET", fmt.Sprintf("https://api.twitter.com/1.1/statuses/show.json?id=%d&include_entities=true&include_ext_alt_text=true", tid), nil)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue