-
-
Notifications
You must be signed in to change notification settings - Fork 418
get_trends deprecation update/fix #390
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
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis PR replaces the old v11 guide-based trends fetch with a GraphQL GenericTimelineById call, adding new endpoints, feature-flag maps, and updating the Trend model to align with the new response shape. Sequence diagram for updated get_trends flow using GenericTimelineByIdsequenceDiagram
participant Client
participant GQL
participant "GenericTimelineById Endpoint"
participant Trend
Client->>GQL: generic_timeline_by_id(timeline_id, count)
GQL->>"GenericTimelineById Endpoint": gql_get(...)
"GenericTimelineById Endpoint"-->>GQL: Response (entries)
GQL-->>Client: Response (entries)
loop For each entry
Client->>Trend: Trend(self, entry['content']['itemContent'])
end
Client-->>Client: Return list of Trend objects
Updated class diagram for Trend modelclassDiagram
class Trend {
- _client: Client
- name: str
- tweets_count: str | None
- domain_context: str
- grouped_trends: list[str]
+ __init__(client: Client, data: dict)
+ __repr__() -> str
}
Trend <-- Client
Class diagram for new GQL methods and endpoint constantsclassDiagram
class GQL {
+ explore_page()
+ generic_timeline_by_id(timeline_id, count)
}
class Endpoint {
+ EXPLORE_PAGE
+ GENERIC_TIMELINE_BY_ID
}
GQL --> Endpoint
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
WalkthroughShifts trends retrieval from v11.guide to a timeline-id driven GraphQL flow, adding new endpoints and feature-flag constants, updating response parsing and retry logic, renaming trend fields to snake_case, and updating .gitignore to ignore Python bytecode. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as Caller
participant C as Client.get_trends(category, count, retry)
participant K as Constants (TIMELINE_IDS, FEATURES)
participant G as GQLClient
participant E as Endpoint.GENERIC_TIMELINE_BY_ID
participant P as Trend parser
U->>C: get_trends(category, count, retry)
C->>K: Lookup timeline_id = TIMELINE_IDS[category]
alt Unknown category
C-->>U: []
else Known category
C->>G: generic_timeline_by_id(timeline_id, count, FEATURES)
G->>E: Request (id, count, features)
E-->>G: Response (entries)
G-->>C: entries
C->>C: Filter entries with entryId starting "trend"
alt No trend entries and retry
C->>C: Recursive get_trends(category, count, retry=false)
C-->>U: Result
else Have trend entries
C->>P: Build Trend objects from entry.content.itemContent
P-->>C: Trend[]
C-->>U: Trend[]
end
end
rect rgba(200,230,255,0.25)
note right of E: New timeline-id GraphQL flow replaces v11.guide
end
rect rgba(220,255,220,0.18)
note right of C: Updated parsing path and retry behavior
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)twikit/client/client.py (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
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 (5)
.gitignore
(1 hunks)twikit/client/client.py
(2 hunks)twikit/client/gql.py
(3 hunks)twikit/constants.py
(1 hunks)twikit/trend.py
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
twikit/client/client.py (2)
twikit/client/gql.py (1)
generic_timeline_by_id
(312-317)twikit/utils.py (1)
find_dict
(111-127)
twikit/client/gql.py (1)
twikit/client/v11.py (1)
Endpoint
(14-50)
Check issue #389. Updated from
guilds.json
toGenericTimelineById
Summary by Sourcery
Switch get_trends to use the GenericTimelineById GraphQL endpoint instead of the legacy v1.1 guide API, introduce feature flags and helper methods for explore_page and generic_timeline_by_id, add a mapping of timeline IDs for trending categories, and update the Trend model to parse snake_case fields from the new response.
Enhancements:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Chores