-
-
Notifications
You must be signed in to change notification settings - Fork 302
feat: added bacon integation in challenges #4445
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
WalkthroughThe changes introduce BACON tokens as an additional reward for completing challenges, alongside existing points. This involves updating the Challenge model, UI templates for both team and user challenges, and backend logic to award BACON tokens upon challenge completion. Supporting settings and a database migration are also included. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ChallengeSystem
participant giveBacon
User->>ChallengeSystem: Complete Challenge (Individual or Team)
ChallengeSystem->>giveBacon: Award BACON tokens (per user/team member)
giveBacon-->>ChallengeSystem: BACON tokens granted
ChallengeSystem-->>User: Challenge completion confirmed, rewards updated
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
🔇 Additional comments (5)
✨ Finishing Touches
🧪 Generate unit tests
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:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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
♻️ Duplicate comments (1)
website/migrations/0178_add_bacon_reward_to_challenge.py (1)
1-17: Critical: This migration duplicates migration 0243This migration adds the same
bacon_rewardfield that migration0243_add_bacon_reward_to_challenge.pyalso adds. This duplication will cause migration conflicts.The comment indicates this was "Generated manually" while 0243 was auto-generated. Please coordinate to ensure only one of these migrations exists in the final codebase.
🧹 Nitpick comments (1)
website/templates/user_challenges.html (1)
104-105: Consider moving Alpine.js to base template for consistency.Loading Alpine.js directly in this template works, but consider moving it to the base template if other pages also use Alpine.js to avoid duplicate script loading and ensure consistent versions across the application.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting
📒 Files selected for processing (9)
website/challenge_signals.py(4 hunks)website/migrations/0178_add_bacon_reward_to_challenge.py(1 hunks)website/migrations/0179_update_challenge_bacon_rewards.py(1 hunks)website/migrations/0243_add_bacon_reward_to_challenge.py(1 hunks)website/migrations/0244_update_existing_challenges_bacon_rewards.py(1 hunks)website/models.py(1 hunks)website/templates/team_challenges.html(2 hunks)website/templates/user_challenges.html(1 hunks)website/views/user.py(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: validate_pr_closing_issues
- GitHub Check: Run Tests
- GitHub Check: docker-test
🔇 Additional comments (15)
website/models.py (1)
1605-1605: LGTM: Clean field addition for BACON token rewardsThe
bacon_rewardfield addition is well-implemented with an appropriate default value and clear naming convention.website/templates/team_challenges.html (2)
14-16: Good: Clear messaging about BACON token rewardsThe updated header text effectively communicates the new BACON token reward system alongside existing points and leaderboard functionality.
34-39: LGTM: Well-integrated BACON token displayThe BACON token display is well-implemented with:
- Consistent styling matching the points display
- Appropriate icon usage (
fas fa-bacon)- Clear labeling with token amount
- Proper spacing and visual hierarchy
website/views/user.py (1)
977-980: LGTM: Progress circle calculations are mathematically correct.The SVG progress circle calculations properly implement a circular progress indicator where the stroke dash offset creates a visual progress fill effect. The circumference value (125.6) matches 2πr for r=20, and the offset formula correctly calculates the visible portion based on progress percentage.
website/challenge_signals.py (4)
42-47: LGTM: Team BACON token rewards properly implemented.The BACON token awarding logic correctly iterates through all team members and awards tokens upon challenge completion. The local import of
giveBaconis appropriate to avoid potential circular imports, and the null check forteam_member.userprevents errors.
66-69: LGTM: Individual BACON token rewards consistently implemented.The individual challenge BACON token awarding follows the same pattern as team challenges, maintaining consistency across the codebase. The placement after point awarding ensures proper reward sequencing.
170-173: LGTM: Sign-in challenge BACON tokens follow consistent pattern.The BACON token implementation for sign-in challenges maintains the same structure as other challenge types, ensuring consistency across the reward system.
215-220: LGTM: Team sign-in challenge BACON tokens implemented consistently.The team sign-in challenge BACON token implementation mirrors the pattern used in other team challenges, including proper iteration through team members and null safety checks.
website/migrations/0244_update_existing_challenges_bacon_rewards.py (2)
6-29: LGTM: Migration safely updates BACON rewards with appropriate values.The migration properly handles updating existing challenges with BACON rewards. The reward values are well-balanced (higher for team challenges), and the try/catch pattern gracefully handles missing challenges. The print statements provide useful feedback during migration execution.
31-34: LGTM: Reverse migration provides clean rollback.The reverse migration efficiently resets all BACON rewards to the default value using a bulk update, providing a clean way to rollback the changes if needed.
website/migrations/0179_update_challenge_bacon_rewards.py (1)
6-35: Verify migration sequence and BACON reward consistencyWe’ve confirmed that:
- 0179_update_challenge_bacon_rewards (depends on 0178) sets:
- Team challenges: “Report 10 IPs”=10, “Report 10 Issues”=10, “All Members Sign in for 5 Days”=15
- Single challenges: “Report 5 IPs”=5, “Report 5 Issues”=5, “Sign in for 5 Days”=8
- 0244_update_existing_challenges_bacon_rewards (depends on 0243) then sets:
- “Report 5 IPs”=10, “Report 5 Issues”=15, “Sign in for 5 Days”=5
- “Report 10 IPs”=20, “Report 10 Issues”=25, “All Members Sign in for 5 Days”=10
Because migration 0243 re-adds or alters the
bacon_rewardfield, 0179’s updates may be overwritten before 0244 runs. Please verify that applying all migrations from a fresh database produces the intended final BACON rewards. In particular:
- Confirm the dependency chain:
0178_add_bacon_reward→0179_update_*→ … →0243_add_bacon_reward→0244_update_*.- Ensure no intermediate drop of the
bacon_rewardcolumn discards 0179’s work.- Consider consolidating or removing the now-superseded 0179 migration if it only affects data that will be reset later.
website/templates/user_challenges.html (4)
4-17: LGTM: Header section provides clear context and modern design.The new header section effectively communicates the purpose of individual challenges with a clean, professional design. The icon and descriptive text help users understand they can earn both points and BACON tokens.
32-43: LGTM: BACON token integration is prominent and well-designed.The BACON token display alongside points provides clear visibility of the new reward system. The bacon icon and completion badge enhance the user experience and make the reward structure immediately apparent.
48-57: LGTM: Circular progress indicator properly utilizes backend calculations.The SVG circular progress indicator correctly uses the
stroke_dasharrayandstroke_dashoffsetvalues calculated in theUserChallengeListView, creating a visually appealing progress representation that's consistent with the team challenges interface.
64-88: LGTM: Interactive details section with appropriate completion states.The Alpine.js-powered collapsible details provide smooth animations and clear action states. The conditional rendering between "Start Challenge" and "Challenge Completed!" buttons appropriately reflects the user's progress status.
|
@CodeRabbit , review |
|
Tip For best results, initiate chat on the files or code changes. @krrish-sehgal Thank you for requesting a review! I've analyzed your BACON token integration PR and here's my comprehensive assessment: 🎯 Overall AssessmentThis is a well-structured implementation that successfully integrates BACON tokens as an additional reward mechanism for challenges. The changes are comprehensive and touch all the necessary components. ✅ Strengths1. Comprehensive Integration
2. UI/UX Improvements
3. Code Quality
|
|
@CodeRabbit approve |
✅ Actions performedComments resolved and changes approved. |
fixes #4334
With integration of bacon in challenges and also changed the UI for single user challenges to be more consistent with team challenges.
Summary by CodeRabbit
New Features
Enhancements
Chores