-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 2 more fields to Tweet object for richer parsing #57
Conversation
WalkthroughThe pull request introduces two optional properties to the Changes
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/tweets.ts
(2 hunks)
🔇 Additional comments (1)
src/tweets.ts (1)
173-173
: LGTM! The interface changes look good.The new optional properties
language
andquotes
are well-typed and properly positioned within the interface.Also applies to: 182-182
@@ -170,6 +170,7 @@ export interface Tweet { | |||
isReply?: boolean; | |||
isRetweet?: boolean; | |||
isSelfThread?: boolean; | |||
language?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Implement parsing for the new properties.
The new properties language
and quotes
are not being populated in the parsing functions. Consider updating the following functions to parse these properties:
parseTweetV2ToV1
: Parselang
fromtweetV2
for thelanguage
propertyparseTweetV2ToV1
: Parsequote_count
fromtweetV2.public_metrics
for thequotes
property
Apply this diff to implement the parsing:
parsedTweet = {
id: tweetV2.id,
text: tweetV2.text ?? defaultTweetData?.text ?? '',
+ language: tweetV2.lang ?? defaultTweetData?.language,
hashtags:
tweetV2.entities?.hashtags?.map((tag) => tag.tag) ??
defaultTweetData?.hashtags ??
[],
mentions:
tweetV2.entities?.mentions?.map((mention) => ({
id: mention.id,
username: mention.username,
})) ??
defaultTweetData?.mentions ??
[],
urls:
tweetV2.entities?.urls?.map((url) => url.url) ??
defaultTweetData?.urls ??
[],
likes: tweetV2.public_metrics?.like_count ?? defaultTweetData?.likes ?? 0,
retweets:
tweetV2.public_metrics?.retweet_count ?? defaultTweetData?.retweets ?? 0,
+ quotes:
+ tweetV2.public_metrics?.quote_count ?? defaultTweetData?.quotes ?? 0,
replies:
tweetV2.public_metrics?.reply_count ?? defaultTweetData?.replies ?? 0,
Also applies to: 182-182
Required for elizaOS/eliza#2644
Summary by CodeRabbit