-
-
Notifications
You must be signed in to change notification settings - Fork 290
Nestbot /events command refactor #1433
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
Conversation
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThe changes refactor the handling and display of events in the Slack integration. The backend logic for gathering event data now returns a flat list of up to nine upcoming events, each including a location field, instead of grouping events by category. The Jinja template is updated to display this flat list without category headers, and to show the event location. The utility function for fetching events is modified to accept a limit parameter, defaulting to nine events. Corresponding tests are updated to reflect the new data structure and output format. Changes
Assessment against linked issues
✨ Finishing Touches
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. 🪧 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
Documentation and Community
|
/events command refactor
/events command refactorThere 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: 0
🧹 Nitpick comments (2)
backend/apps/slack/utils.py (1)
120-120: Update function docstring to include the new parameterThe function signature has been updated to include a
limitparameter, but the docstring doesn't mention it. Please update the docstring to document this parameter.def get_events_data(limit=9): """Get events data. + + Args: + limit (int, optional): The maximum number of events to fetch. Defaults to 9. Returns QuerySet or None: A queryset of upcoming events.backend/apps/slack/commands/events.py (1)
19-28: Verify if sorting is necessaryThe code at line 15 sorts the events by start date, but
get_events_data()already returns events ordered by start date (as seen in utils.py). Consider removing the redundant sorting to improve performance.- sorted_events = sorted(valid_events, key=lambda x: x.start_date) + sorted_events = valid_events
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
backend/apps/slack/commands/events.py(1 hunks)backend/apps/slack/templates/events.jinja(1 hunks)backend/apps/slack/utils.py(2 hunks)backend/tests/apps/slack/commands/events_test.py(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
backend/apps/slack/utils.py (1)
backend/apps/owasp/models/event.py (1)
Event(15-284)
backend/apps/slack/commands/events.py (2)
backend/apps/owasp/models/event.py (1)
upcoming_events(57-68)backend/apps/slack/commands/command.py (1)
get_template_context(47-62)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Run backend tests
- GitHub Check: Run frontend unit tests
- GitHub Check: Run frontend e2e tests
- GitHub Check: CodeQL (python)
- GitHub Check: CodeQL (javascript-typescript)
🔇 Additional comments (9)
backend/apps/slack/utils.py (1)
130-130: LGTM! Optimized database queryGood optimization that limits the number of records fetched from the database, which aligns with the PR objective to display a limited set of upcoming events.
backend/apps/slack/templates/events.jinja (1)
2-4: LGTM! Template updated correctly for flat event listThe template has been appropriately updated to:
- Iterate over a flat list of events instead of category-grouped events
- Add numeric indexing to the events
- Display the event location information
This change aligns with the PR objective to make the event display consistent with the main page.
backend/apps/slack/commands/events.py (3)
17-18: LGTM! Changed to flat event list structureGood restructuring of the event data from category-based to a simple flat list, which aligns with the PR objective.
25-25: LGTM! Added location informationGood addition of location data from
event.suggested_location, which aligns with the PR objective to make event details more consistent with the main page.
32-33: LGTM! Updated context structureThe context structure has been correctly updated to match the new event data organization expected by the template.
backend/tests/apps/slack/commands/events_test.py (4)
9-16: LGTM! Updated MockEvent classThe MockEvent class constructor has been correctly updated to use
suggested_locationinstead ofcategory, aligning with the model changes.
19-39: LGTM! Updated mock event dataMock events have been appropriately updated to include location information and are pre-sorted by start date, which matches the expected behavior of the actual implementation.
90-111: LGTM! Updated test assertions for first eventThe test assertions have been updated to verify the presence and correctness of all fields for the first event, including the new location information.
112-130: LGTM! Added test assertions for second event and footerGood addition of detailed assertions for the second event and footer block, ensuring comprehensive test coverage of the new event display format.
|
@arkid15r It is ready for review :) -- should we keep the description or remove it? |
arkid15r
left a 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.
LGTM
|
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: 0
🧹 Nitpick comments (1)
backend/apps/slack/commands/events.py (1)
22-22: Consider explicitly specifying the event limit.The AI summary mentions that
get_events_data()now supports a limit parameter defaulting to nine events. For clarity and to make the code more self-documenting, consider explicitly passing this limit:- for event in sorted(get_events_data(), key=lambda e: e.start_date) + for event in sorted(get_events_data(limit=9), key=lambda e: e.start_date)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
backend/apps/slack/commands/events.py(1 hunks)backend/apps/slack/templates/events.jinja(1 hunks)backend/apps/slack/utils.py(2 hunks)backend/tests/apps/slack/commands/events_test.py(3 hunks)frontend/src/server/queries/homeQueries.ts(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- frontend/src/server/queries/homeQueries.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- backend/apps/slack/utils.py
- backend/apps/slack/templates/events.jinja
- backend/tests/apps/slack/commands/events_test.py
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Run frontend unit tests
- GitHub Check: Run frontend e2e tests
- GitHub Check: Run backend tests
- GitHub Check: CodeQL (python)
- GitHub Check: CodeQL (javascript-typescript)
🔇 Additional comments (2)
backend/apps/slack/commands/events.py (2)
13-23: Improved event data structure with cleaner implementation.The refactoring simplifies the event data handling by creating a flat list of events sorted by start date, which aligns well with the PR objective of matching the main page format. The code is now more maintainable and easier to understand.
27-27: Good naming for flat event list.The context key
"upcoming_events"clearly communicates the content and purpose of this data structure, making the template implementation more intuitive.
* events command refactored * format changed * Update code --------- Co-authored-by: Arkadii Yakovets <[email protected]>




Resolves #1427
Refactored nest bot
/eventscommand to display info same as main page