-
-
Notifications
You must be signed in to change notification settings - Fork 41
feat: added uptime and current branch to status #989
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
Reviewer's GuideThis PR enhances the existing ping command (now also aliased as status) by recording the bot’s start time at initialization and displaying its uptime and current environment in the response. Class diagram for updated Tux bot and Ping commandclassDiagram
class Tux {
+float uptime
}
class Ping {
+ping(ctx)
}
Tux <|-- Ping: uses
Ping : +aliases = ["status"]
Ping : +Displays uptime
Ping : +Displays environment
Ping : +Displays CPU/RAM
Ping : +Displays latency
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
4ecf65c to
fb28e47
Compare
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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.
Hey @cherryl1k - I've reviewed your changes - here's some feedback:
- Consider storing
self.uptimeas a datetime object rather than a timestamp to keep uptime calculations timezone-aware and simplify conversions. - You can clean up the uptime formatting by filtering out empty segments (e.g.
[part for part in parts if part]) instead of joining empty strings and stripping. - Extract the uptime calculation and formatting into a small helper function to keep the
pingcommand handler focused and more testable.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider storing `self.uptime` as a datetime object rather than a timestamp to keep uptime calculations timezone-aware and simplify conversions.
- You can clean up the uptime formatting by filtering out empty segments (e.g. `[part for part in parts if part]`) instead of joining empty strings and stripping.
- Extract the uptime calculation and formatting into a small helper function to keep the `ping` command handler focused and more testable.
## Individual Comments
### Comment 1
<location> `tux/cogs/utility/ping.py:47` </location>
<code_context>
+ minutes, seconds = divmod(remainder, 60)
+
+ # Format it for the command
+ bot_uptime_readable = " ".join(
+ [f"{days}d" if days else "", f"{hours}h" if hours else "", f"{minutes}m" if minutes else "", f"{seconds}s"],
+ ).strip()
+
# Get the CPU usage and RAM usage of the bot
</code_context>
<issue_to_address>
The formatting may produce extra spaces if some time units are zero.
Filter out empty strings before joining to avoid extra spaces in the output.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
# Format it for the command
bot_uptime_readable = " ".join(
[f"{days}d" if days else "", f"{hours}h" if hours else "", f"{minutes}m" if minutes else "", f"{seconds}s"],
).strip()
=======
# Format it for the command
bot_uptime_parts = [
f"{days}d" if days else "",
f"{hours}h" if hours else "",
f"{minutes}m" if minutes else "",
f"{seconds}s"
]
bot_uptime_readable = " ".join(part for part in bot_uptime_parts if part)
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
tux/cogs/utility/ping.py
Outdated
| # Format it for the command | ||
| bot_uptime_readable = " ".join( | ||
| [f"{days}d" if days else "", f"{hours}h" if hours else "", f"{minutes}m" if minutes else "", f"{seconds}s"], | ||
| ).strip() |
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.
suggestion: The formatting may produce extra spaces if some time units are zero.
Filter out empty strings before joining to avoid extra spaces in the output.
| # Format it for the command | |
| bot_uptime_readable = " ".join( | |
| [f"{days}d" if days else "", f"{hours}h" if hours else "", f"{minutes}m" if minutes else "", f"{seconds}s"], | |
| ).strip() | |
| # Format it for the command | |
| bot_uptime_parts = [ | |
| f"{days}d" if days else "", | |
| f"{hours}h" if hours else "", | |
| f"{minutes}m" if minutes else "", | |
| f"{seconds}s" | |
| ] | |
| bot_uptime_readable = " ".join(part for part in bot_uptime_parts if part) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #989 +/- ##
========================================
+ Coverage 9.26% 9.44% +0.17%
========================================
Files 123 123
Lines 10392 10406 +14
Branches 1277 1277
========================================
+ Hits 963 983 +20
- Misses 9327 9330 +3
+ Partials 102 93 -9
*This pull request uses carry forward flags. Click here to find out more.
☔ View full report in Codecov by Sentry. |
fb28e47 to
b3000b7
Compare
Deploying tux with
|
| Latest commit: |
3e97a4c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://fc8b334e.tux-afh.pages.dev |
| Branch Preview URL: | https://feature-add-uptime-to-ping.tux-afh.pages.dev |
b425ac4 to
68f30f8
Compare
68f30f8 to
3e97a4c
Compare
Description
Add uptime and the current environment (dev/prod) to the ping command aswell as aliasing it to status
Guidelines
My code follows the style guidelines of this project (formatted with Ruff)
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation if needed
My changes generate no new warnings
I have tested this change
Any dependent changes have been merged and published in downstream modules
I have added all appropriate labels to this PR
I have followed all of these guidelines.
How Has This Been Tested? (if applicable)
tested within my discord server while monitoring my tux console
Screenshots (if applicable)
Summary by Sourcery
Enhance the ping command (aliased as status) to include bot uptime and current environment
New Features:
Enhancements: