Skip to content
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

1.2.5.1 #150

Merged
merged 7 commits into from
Nov 7, 2024
Merged

1.2.5.1 #150

merged 7 commits into from
Nov 7, 2024

Conversation

cohenaj194
Copy link
Contributor

@cohenaj194 cohenaj194 commented Nov 7, 2024

Summary by CodeRabbit

  • New Features

    • Alerts are now consolidated into a single message per realm, improving clarity and organization.
    • Enhanced item link generation in alerts for better user experience.
    • Updated compatibility for running the script in Windows environments.
  • Bug Fixes

    • Improved error handling in auction data requests, allowing the program to continue running without interruptions when encountering rate limits.
  • Documentation

    • Updated comments to reflect changes in error handling and alert messaging structure.
  • Chores

    • Version number updated from 1.2.5 to 1.2.5.1.
    • Number of mega threads reduced from 48 to 10.

Copy link
Contributor

coderabbitai bot commented Nov 7, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request primarily involve modifications to four files: mega_alerts.py, utils/mega_data_setup.py, .github/workflows/windows-exe-build.yml, and AzerothAuctionAssassin.py. In mega_alerts.py, the Alerts class has been updated to consolidate alerts into a single embed per realm and improve link generation. In utils/mega_data_setup.py, the error handling for API requests has been enhanced to allow more retries and manage HTTP 429 status codes more efficiently. The GitHub Actions workflow has been updated to reflect a new version number for the Windows executable build, and the version number in AzerothAuctionAssassin.py has been updated alongside enhancements for Windows compatibility.

Changes

File Change Summary
mega_alerts.py Updated Alerts class to consolidate alert messages into a single embed; revised format_alert_messages for better link generation; streamlined logging and removed outdated code.
utils/mega_data_setup.py Enhanced error handling in MegaData class with increased retry attempts for API requests; adjusted handling of HTTP 429 status code to log an error and continue execution.
.github/workflows/windows-exe-build.yml Updated environment variable AAA_VERSION from "1.2.5" to "1.2.5.1" for the Windows executable build process.
AzerothAuctionAssassin.py Updated version number from 1.2.5 to 1.2.5.1; added compatibility code for Windows invocation; simplified error handling.

Possibly related PRs

  • 1.2.5 #145: The changes in mega_alerts.py regarding the handling of required_lvl directly relate to the modifications made in the same file in this PR, which also enhances the alerting functionality by integrating level requirements into the auction alerting process.

Poem

🐇 In the realm of alerts, a change took flight,
Messages now gathered, a beautiful sight.
No more long waits for requests that delay,
Just swift little bunnies hopping on their way!
With links shining bright, and alerts all in line,
The code's now a garden, blooming just fine! 🌼


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (1)
mega_alerts.py (1)

591-591: LGTM! Consider a minor formatting improvement.

The addition of ilvl items list logging improves visibility. For consistency with the previous lines, consider adding quotes around the list reference.

-            + f"or ilvl items from list {mega_data.DESIRED_ILVL_LIST}\n"
+            + f"or ilvl items from list '{mega_data.DESIRED_ILVL_LIST}'\n"
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0b347d4 and 5af56e7.

📒 Files selected for processing (2)
  • mega_alerts.py (1 hunks)
  • utils/mega_data_setup.py (1 hunks)
🔇 Additional comments (1)
utils/mega_data_setup.py (1)

631-638: Verify handling of empty auction lists downstream.

The change to return empty auction lists instead of raising exceptions could affect downstream functionality. Please ensure that:

  1. The alerting system in mega_alerts.py properly handles empty auction lists
  2. No critical functionality depends on having commodity data for every scan
✅ Verification successful

Based on the results, I can generate the final response as we have clear evidence of empty auction list handling.

Empty auction lists are properly handled downstream ✓

The alerting system in mega_alerts.py has proper validation for empty auction lists:

  • Explicit check if not clean_auctions or len(clean_auctions) == 0: return
  • Additional validation if len(auctions) == 0: return

The change to return empty auction lists instead of raising exceptions is safe as the downstream code gracefully handles this case by simply returning without processing.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for auction list handling in mega_alerts.py
echo "Checking auction list handling in mega_alerts.py:"
rg -A 5 "auctions\[" mega_alerts.py

# Search for empty list checks
echo "Checking empty list validation:"
rg -A 5 "len\(.*auctions" mega_alerts.py

Length of output: 1508

utils/mega_data_setup.py Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (4)
.github/workflows/windows-exe-build.yml (1)

Line range hint 123-127: Consider fixing the macOS code signing.

The commented-out macOS signing step indicates an unresolved certificate issue. This means macOS builds are being released unsigned, which could cause security warnings for users.

Would you like help with:

  1. Documenting the requirements for a valid macOS signing certificate?
  2. Creating a separate issue to track this technical debt?
AzerothAuctionAssassin.py (3)

Line range hint 8-21: Consider improving error handling and path validation.

The current implementation has several areas that could be improved:

  1. The broad exception handling with silent pass could mask important errors
  2. The sys.path modification lacks validation, which could be a security concern
  3. The code structure could be cleaner than the current "if it isn't broken don't fix it" approach

Consider this safer implementation:

-AAA_VERSION = "1.2.5.1"
+AAA_VERSION = "1.2.5.1"  # Update this version number when releasing new versions

-windowsApp_Path = None
-try:
-    if sys.argv[1] == "run-from-windows-bin":
-        sys.path.append(f"{sys.argv[2]}")
-        sys.path.append(f"{sys.argv[3]}")
-
-        windowsApp_Path = f"{sys.argv[2]}"
-    else:
-        pass
-except Exception as ex:
-    pass
-# i hate the way that looks but if it isnt broken dont fix it
+def setup_windows_paths():
+    """Configure paths when running from Windows binary."""
+    if len(sys.argv) < 4:
+        return None
+    
+    if sys.argv[1] != "run-from-windows-bin":
+        return None
+        
+    # Validate paths before adding to sys.path
+    package_path = sys.argv[2]
+    lib_path = sys.argv[3]
+    
+    if not all(os.path.exists(p) for p in [package_path, lib_path]):
+        raise ValueError("Invalid paths provided for Windows binary execution")
+        
+    sys.path.extend([package_path, lib_path])
+    return package_path
+
+try:
+    windowsApp_Path = setup_windows_paths()
+except (IndexError, ValueError) as e:
+    print(f"Warning: Failed to setup Windows paths - {str(e)}")
+    windowsApp_Path = None

Line range hint 56-58: Use a more specific application identifier.

The current Windows application user model ID is using generic placeholder values. This should be updated to reflect the actual application details.

-myappid = "mycompany.myproduct.subproduct.version"  # arbitrary string
+myappid = f"com.saddlebagexchange.azerothauctionassassin.{AAA_VERSION}"

Line range hint 60-1124: Consider breaking down the large App class into smaller components.

The current implementation has a single large class handling multiple responsibilities. Consider:

  1. Separating UI components into individual classes (e.g., PetPage, ItemPage, etc.)
  2. Moving validation logic into a separate service layer
  3. Implementing a proper MVC/MVVM pattern

This would improve:

  • Code maintainability
  • Testing capabilities
  • Feature development
  • Code reuse
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5af56e7 and 68f3d2a.

📒 Files selected for processing (2)
  • .github/workflows/windows-exe-build.yml (1 hunks)
  • AzerothAuctionAssassin.py (1 hunks)
🔇 Additional comments (1)
.github/workflows/windows-exe-build.yml (1)

4-4: Version bump follows semantic versioning.

The version increment from 1.2.5 to 1.2.5.1 follows semantic versioning principles, where the fourth number typically indicates a patch or build number. This is appropriate for minor fixes.

Let's verify version consistency across the project:

✅ Verification successful

Version number is consistently updated across the codebase

The version number 1.2.5.1 is consistently defined in both the GitHub Actions workflow (.github/workflows/windows-exe-build.yml) and the main application file (AzerothAuctionAssassin.py). No inconsistencies were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check version number consistency across the project
# Look for version strings in Python files and other configuration files
rg -g '!.git' "1\.2\.5\.1|1\.2\.5"

Length of output: 86

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (3)
utils/mega_data_setup.py (3)

560-564: Consider adding exponential backoff to retry strategy.

While the increased retry attempts and exception handling are good improvements, the retry strategy could be enhanced further.

Consider adding exponential backoff to avoid overwhelming the API:

     @retry(
         stop=stop_after_attempt(10),
         retry=retry_if_exception_type(requests.RequestException),
+        wait=wait_exponential(multiplier=1, min=4, max=10),
         retry_error_callback=lambda retry_state: {"auctions": []},
     )

571-572: Consider dynamic sleep duration for rate limiting.

The fixed 3-second sleep might not be optimal for all rate-limiting scenarios.

Consider extracting the retry-after header if available:

         if req.status_code == 429:
             error_message = f"{req} BLIZZARD too many requests error on {self.REGION} {str(connectedRealmId)} realm data, skipping"
-            time.sleep(3)
+            retry_after = int(req.headers.get('Retry-After', 3))
+            time.sleep(retry_after)
             raise Exception(error_message)

571-572: Consider centralizing error handling logic.

The error handling logic is duplicated between make_ah_api_request and make_commodity_ah_api_request.

Consider extracting the common error handling logic into a helper method:

+    def _handle_api_error(self, req, region, realm_id, is_commodity=False):
+        if req.status_code == 429:
+            data_type = "commodities" if is_commodity else "realm"
+            error_message = f"{req} BLIZZARD too many requests error on {region} {data_type} data, skipping"
+            retry_after = int(req.headers.get('Retry-After', 3))
+            time.sleep(retry_after)
+            raise Exception(error_message)
+        elif req.status_code != 200:
+            error_message = f"{req} BLIZZARD error getting {region} {str(realm_id)} realm data"
+            print(error_message)
+            time.sleep(1)
+            raise Exception(error_message)

Then use it in both methods:

self._handle_api_error(req, self.REGION, connectedRealmId)  # for AH API
self._handle_api_error(req, self.REGION, connectedRealmId, is_commodity=True)  # for commodity API

Also applies to: 637-638

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ff4f6e9 and f3fcbc8.

📒 Files selected for processing (2)
  • AzerothAuctionAssassin.py (4 hunks)
  • utils/mega_data_setup.py (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • AzerothAuctionAssassin.py
🔇 Additional comments (3)
utils/mega_data_setup.py (3)

227-227: LGTM: Increased retry attempts for access token.

The retry attempts for obtaining an access token have been increased from 3 to 10, which is a reasonable improvement for handling temporary API issues.


616-620: Ensure consistent retry configuration across API calls.

The retry configuration for commodity API requests matches the AH API requests, which is good for consistency.


637-638: Maintain consistent error handling across API calls.

The error handling for commodity API requests matches the AH API requests, which is good for consistency.

@cohenaj194 cohenaj194 merged commit ab48fb6 into main Nov 7, 2024
1 of 2 checks passed
Copy link

sonarqubecloud bot commented Nov 7, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
8.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

This was referenced Nov 15, 2024
@cohenaj194 cohenaj194 changed the title commodities and grammar fixes 1.2.5.1 Nov 22, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 22, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant