Skip to content

Commit

Permalink
Merge pull request #646 from DocNow/flatten-matching-rules
Browse files Browse the repository at this point in the history
Append matching rules from stream when flattening
  • Loading branch information
edsu committed Jun 30, 2022
2 parents 067f140 + bcaefd4 commit e215d89
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion twarc/expansions.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,13 @@ def expand_payload(payload):
elif isinstance(data, dict):
tweets = [expand_payload(response["data"])]

# Add the __twarc metadata to each tweet if it's a result set
# Add the __twarc metadata and matching rules to each tweet if it's a result set
if "__twarc" in response:
for tweet in tweets:
tweet["__twarc"] = response["__twarc"]
if "matching_rules" in response:
for tweet in tweets:
tweet["matching_rules"] = response["matching_rules"]
else:
raise ValueError(f"missing data stanza in response: {response}")

Expand Down

0 comments on commit e215d89

Please sign in to comment.