Skip to content

Commit

Permalink
append matching rules from stream when flattening
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbrigadir committed Jun 30, 2022
1 parent 067f140 commit bcaefd4
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 bcaefd4

Please sign in to comment.