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

Исправить подсчет времени выполнения запросов в батче #230

Merged
merged 4 commits into from
Mar 23, 2024

Conversation

leshchenko1979
Copy link
Owner

No description provided.

@leshchenko1979 leshchenko1979 self-assigned this Mar 23, 2024
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @leshchenko1979 - I've reviewed your changes and they look great!

General suggestions:

  • Consider adding comprehensive error handling within the new 'add_throttler_records' method to ensure robustness in face of unexpected JSON structures.
  • Simplify the 'add_throttler_records' method to improve code maintainability and readability, potentially by reducing branching logic and focusing on core functionality.
  • Review the newly introduced warnings for parameter misuse to ensure they are clear and actionable for the users.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Docstrings: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines +176 to +186
def add_throttler_records(self, method, params: dict, json: dict):
if "result_time" in json:
for cmd_name, cmd_url in params["cmd"].items():
item_method = cmd_url.split("?")[0]
item_time = json["result_time"][cmd_name]
self.method_throttlers[item_method].add_request_record(item_time)
else:
request_run_time = json["time"]["operating"]
self.method_throttlers[method].add_request_record(request_run_time)

self.leaky_bucket_throttler.add_request_record()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (edge_case_not_handled): Ensure error handling in 'add_throttler_records' method.

Given the critical nature of throttling in API interactions, consider adding error handling within 'add_throttler_records' to manage unexpected 'json' structures or missing keys.

fast_bitrix24/srh.py Show resolved Hide resolved
Copy link

codecov bot commented Mar 23, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 88.68%. Comparing base (7efa74c) to head (65ca05e).

Files Patch % Lines
fast_bitrix24/srh.py 60.00% 4 Missing ⚠️
fast_bitrix24/user_request.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #230      +/-   ##
==========================================
- Coverage   89.50%   88.68%   -0.82%     
==========================================
  Files          11       11              
  Lines         581      592      +11     
==========================================
+ Hits          520      525       +5     
- Misses         61       67       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leshchenko1979 leshchenko1979 merged commit 0f0f813 into master Mar 23, 2024
9 of 11 checks passed
@leshchenko1979 leshchenko1979 deleted the leshchenko1979/issue187 branch March 23, 2024 22:27
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