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

Fix server response parsing #221

Merged
merged 3 commits into from
Mar 18, 2024
Merged

Fix server response parsing #221

merged 3 commits into from
Mar 18, 2024

Conversation

leshchenko1979
Copy link
Owner

No description provided.

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

codecov bot commented Mar 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.90%. Comparing base (5b62295) to head (38ca64f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #221      +/-   ##
==========================================
+ Coverage   88.55%   88.90%   +0.35%     
==========================================
  Files          11       11              
  Lines         559      559              
==========================================
+ Hits          495      497       +2     
+ Misses         64       62       -2     

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

@leshchenko1979 leshchenko1979 merged commit 4a450b3 into master Mar 18, 2024
11 checks passed
@leshchenko1979 leshchenko1979 deleted the leshchenko1979/issue210 branch March 18, 2024 15:06
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 further modularization of the response parsing logic to facilitate future enhancements.
  • Review the consistency of method documentation to ensure clarity across the codebase.
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Docstrings: all looks good

Thanks for using Sourcery. We offer it for free for open source projects and would be very grateful if you could help us grow. If you like it, would you consider sharing Sourcery on your favourite social media? ✨

Share Sourcery

Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines +36 to +41
def generate_tasks(self):
"""Group items in batches and create asyncio tasks for each batch"""

batches = (
{
"halt": 0,
"cmd": {
self.batch_command_label(
i, item
): f"{self.method}?{http_build_query(item)}"
for i, item in enumerate(next_batch)
},
}
for next_batch in chunked(self.item_list, BITRIX_MAX_BATCH_SIZE)
self.package_batch(chunk)
for chunk in chunked(self.item_list, BITRIX_MAX_BATCH_SIZE)
Copy link

Choose a reason for hiding this comment

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

suggestion (code_refinement): Refactoring generate_a_task to generate_tasks improves readability and intent clarity.

Comment on lines +47 to +54
def package_batch(self, chunk):
return {
"halt": 0,
"cmd": {
f"cmd{i:010}": f"{self.method}?{http_build_query(item)}"
for i, item in enumerate(chunk)
},
}
Copy link

Choose a reason for hiding this comment

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

suggestion (code_refinement): Extracting batch packaging logic into package_batch method enhances modularity.

Comment on lines +51 to +53
extracted = self.extract_from_single_response(self.result["result"])

return extracted[0] if isinstance(extracted, list) else extracted
Copy link

Choose a reason for hiding this comment

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

suggestion (code_refinement): Simplifying the return logic for single responses enhances code readability.

Comment on lines 70 to 72
return isinstance(self.result, dict) and "result" in self.result

@staticmethod
def extract_from_single_response(result: dict):
def extract_from_single_response(self, result: dict):
# если результат вызова содержит только словарь {ключ: список},
Copy link

Choose a reason for hiding this comment

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

suggestion (code_refinement): Removing static method in favor of instance method allows for more flexible future extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant