-
Notifications
You must be signed in to change notification settings - Fork 76
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
Resend Broadcast #1318
Resend Broadcast #1318
Conversation
Fixed and added test cases related to the same.
WalkthroughThe updates introduce the ability to resend message broadcasts and enforce retry limits. New endpoints and methods have been added for managing broadcast retries, validating limits, and handling resends. Alterations include new fields for retry counts, additional parameters in broadcast methods, and enhanced logging. Unit tests were also updated to cover the new functionalities and configuration changes. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API
participant Processor
participant Queue
participant Broadcast
User ->> API: Resend broadcast request
API ->> Processor: Validate request
Processor ->> API: Validation result
API ->> Queue: Enqueue resend task
Queue ->> Processor: Process resend task
Processor ->> Broadcast: Resend broadcast
Broadcast ->> Processor: Broadcast status
Processor ->> API: Update log with status
API ->> User: Confirmation response
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration 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: 14
Outside diff range and nitpick comments (1)
kairon/shared/chat/broadcast/processor.py (1)
Line range hint
161-185
:
Replace deprecatedText
withstr
.The
Text
type from thetyping
module is deprecated. Replace it withstr
.- def __add_broadcast_logs_status_and_errors(reference_id: Text, campaign_name: Text, - broadcast_logs: Dict[Text, Document], retry_count: int = 0): + def __add_broadcast_logs_status_and_errors(reference_id: str, campaign_name: str, + broadcast_logs: Dict[str, Document], retry_count: int = 0):Tools
Ruff
188-188:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
188-188:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
188-188:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
198-198: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
201-201:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
201-201:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
209-209:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
209-209:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (16)
- kairon/api/app/routers/bot/channels.py (1 hunks)
- kairon/events/definitions/message_broadcast.py (4 hunks)
- kairon/events/definitions/scheduled_base.py (2 hunks)
- kairon/shared/channels/broadcast/whatsapp.py (3 hunks)
- kairon/shared/chat/broadcast/constants.py (1 hunks)
- kairon/shared/chat/broadcast/data_objects.py (1 hunks)
- kairon/shared/chat/broadcast/processor.py (5 hunks)
- kairon/shared/constants.py (1 hunks)
- kairon/shared/data/data_objects.py (1 hunks)
- system.yaml (1 hunks)
- tests/integration_test/services_test.py (7 hunks)
- tests/testing_data/system.yaml (1 hunks)
- tests/unit_test/action/action_test.py (2 hunks)
- tests/unit_test/channels/broadcast_processor_test.py (3 hunks)
- tests/unit_test/events/definitions_test.py (6 hunks)
- tests/unit_test/events/events_test.py (14 hunks)
Files not summarized due to errors (1)
- tests/unit_test/events/events_test.py: Error: Message exceeds token limit
Files skipped from review due to trivial changes (4)
- kairon/shared/constants.py
- system.yaml
- tests/testing_data/system.yaml
- tests/unit_test/events/definitions_test.py
Additional context used
Ruff
kairon/events/definitions/scheduled_base.py
21-21: Use
key not in dict
instead ofkey not in dict.keys()
Remove
.keys()
(SIM118)
35-35:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
39-39:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
43-43:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
kairon/events/definitions/message_broadcast.py
45-45:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
52-52:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
113-113: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
115-115:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
125-125:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
156-156:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
kairon/api/app/routers/bot/channels.py
188-188: Do not perform function call
Security
in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
kairon/shared/chat/broadcast/processor.py
21-21:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
21-21:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
84-84:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
84-84:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
84-84:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
84-84:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
121-121:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
161-161:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
161-161:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
162-162:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
188-188:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
188-188:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
188-188:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
198-198: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
201-201:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
201-201:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
209-209:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
209-209:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
Additional comments not posted (26)
kairon/shared/chat/broadcast/constants.py (1)
7-7
: LGTM!The addition of the
resend
value to theMessageBroadcastLogType
enum is straightforward and looks good.kairon/shared/chat/broadcast/data_objects.py (1)
91-91
: LGTM!The addition of the
retry_count
field to theMessageBroadcastSettings
class is straightforward and looks good.kairon/shared/channels/broadcast/whatsapp.py (4)
Line range hint
50-66
:
LGTM!The addition of the
retry_count
parameter to thesend_msg
method is a good way to track message retries.
111-121
: LGTM!The addition of the
retry_count
parameter to thesend_template_message
method is a good way to track message retries.
128-162
: LGTM!The
resend_broadcast
function is well-implemented and handles the resending of broadcast messages effectively. The use ofretry_count
to track retries is a good addition.
Line range hint
188-196
:
LGTM!The
update_retry_count
function is well-implemented and updates the retry count for a broadcast message effectively.kairon/api/app/routers/bot/channels.py (1)
185-196
: LGTM!The
resend_message_broadcast_event
endpoint is well-implemented and handles the resending of scheduled message broadcasts effectively. Ensure to fix the security issue flagged above.Tools
Ruff
188-188: Do not perform function call
Security
in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
kairon/shared/chat/broadcast/processor.py (1)
116-119
: Replace deprecatedText
withstr
.The
Text
type from thetyping
module is deprecated. Replace it withstr
.- def get_reference_id_from_broadcasting_logs(event_id: Text): + def get_reference_id_from_broadcasting_logs(event_id: str):Likely invalid or redundant comment.
tests/unit_test/channels/broadcast_processor_test.py (1)
212-228
: LGTM!The
test_get_settings
function is well-implemented and includes assertions for theretry_count
parameter.kairon/shared/data/data_objects.py (1)
936-936
: LGTM!The addition of the
retry_broadcasting_limit
field is consistent with the rest of the class and follows the correct pattern for adding new fields.tests/unit_test/events/events_test.py (7)
1283-1284
: Ensureretry_count
is correctly handled.Verify that the
retry_count
field is correctly managed throughout the broadcast process to avoid any inconsistencies.
1315-1315
: Initialization ofretry_count
looks good.The
retry_count
field is correctly initialized in the broadcast configuration.
1394-1395
: Ensureretry_count
is correctly handled.Verify that the
retry_count
field is correctly managed throughout the broadcast process to avoid any inconsistencies.
1529-1530
: Ensureretry_count
is correctly handled.Verify that the
retry_count
field is correctly managed throughout the broadcast process to avoid any inconsistencies.
1844-1845
: Ensureretry_count
is correctly handled.Verify that the
retry_count
field is correctly managed throughout the broadcast process to avoid any inconsistencies.
1898-1899
: Initialization ofretry_count
looks good.The
retry_count
field is correctly initialized in the broadcast configuration.
2039-2040
: Initialization ofretry_count
looks good.The
retry_count
field is correctly initialized in the broadcast configuration.tests/unit_test/action/action_test.py (2)
2702-2703
: Ensureretry_broadcasting_limit
is tested correctly.The addition of the
retry_broadcasting_limit
field in theBotSettings
class is correctly tested. Ensure that the value3
is appropriate and consistent with the default settings or requirements.
3935-3937
: Ensureretry_broadcasting_limit
is tested correctly.The addition of the
retry_broadcasting_limit
field in theget_bot_settings
method is correctly tested. Ensure that the value3
is appropriate and consistent with the default settings or requirements.tests/integration_test/services_test.py (7)
2062-2095
: LGTM!The test case
test_initiate_bsp_onboarding_for_broadcast
is comprehensive and uses appropriate mocking and monkeypatching.
2097-2122
: LGTM!The test case
test_add_broadcast_message
is comprehensive and uses appropriate mocking.
2124-2152
: LGTM!The test case
test_resend_broadcast_message
is comprehensive and uses appropriate mocking.
2154-2189
: LGTM!The test case
test_resend_broadcast_message_with_retry_limit_exceeded
is comprehensive and uses appropriate monkeypatching and mocking.
2191-2216
: LGTM!The test case
test_list_broadcast
is comprehensive and verifies the retrieval of broadcast messages.
2218-2234
: LGTM!The test case
test_delete_message_broadcast
is comprehensive and uses appropriate mocking.
Line range hint
24488-24493
:
LGTM! But verify the changes align with the context.The changes to the test case
test_get_llm_logs
are partially visible and seem to be part of the existing test case.Verification successful
Verification Successful!
The changes to the test case
test_get_llm_logs
align with the context and the function implementation is correct.
- The function imports necessary modules.
- It sets up an event loop and a logger.
- It makes an async call to
litellm.acompletion
and asserts the expected results.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the changes to the test case `test_get_llm_logs` align with the context. # Test: Search for the function definition. Expect: The function definition and new changes. rg --type python $'def test_get_llm_logs'Length of output: 73
Script:
#!/bin/bash # Description: Verify the changes to the test case `test_get_llm_logs` align with the context. # Locate the file containing the test case fd 'services_test.py' -t f -e py -x rg 'def test_get_llm_logs' {}Length of output: 92
Script:
#!/bin/bash # Description: Extract the full content of the `test_get_llm_logs` function from the `services_test.py` file. # Locate the file containing the test case and extract the function definition and its body. fd 'services_test.py' -t f -e py -x rg -A 20 'def test_get_llm_logs' {}Length of output: 834
Script:
#!/bin/bash # Description: Extract additional lines from the `test_get_llm_logs` function in the `services_test.py` file to capture the complete function body. # Locate the file containing the test case and extract the remaining function body. fd 'services_test.py' -t f -e py -x rg -A 20 'response = client.get' {}Length of output: 275269
@abstractmethod | ||
def _resend_broadcast(self, msg_broadcast_id: Text): | ||
raise NotImplementedError("Provider not implemented") | ||
|
||
@abstractmethod | ||
def delete_schedule(self, msg_broadcast_id: Text): |
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.
Replace deprecated typing.Text
with str
.
The Text
type is deprecated and should be replaced with str
.
- def delete_schedule(self, msg_broadcast_id: Text):
+ def delete_schedule(self, msg_broadcast_id: str):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def delete_schedule(self, msg_broadcast_id: Text): | |
def delete_schedule(self, msg_broadcast_id: str): |
Tools
Ruff
43-43:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
@@ -34,6 +35,10 @@ | |||
def _update_schedule(self, msg_broadcast_id: Text, config: Dict): | |||
raise NotImplementedError("Provider not implemented") | |||
|
|||
@abstractmethod | |||
def _resend_broadcast(self, msg_broadcast_id: Text): |
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.
Replace deprecated typing.Text
with str
.
The Text
type is deprecated and should be replaced with str
.
- def _resend_broadcast(self, msg_broadcast_id: Text):
+ def _resend_broadcast(self, msg_broadcast_id: str):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def _resend_broadcast(self, msg_broadcast_id: Text): | |
def _resend_broadcast(self, msg_broadcast_id: str): |
Tools
Ruff
39-39:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
EventRequestType.update_schedule.value: self._update_schedule, | ||
EventRequestType.resend_broadcast.value: self._resend_broadcast |
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.
Use key not in dict
instead of key not in dict.keys()
.
This is a more Pythonic way to check for the presence of a key in a dictionary.
- if event_request_type not in request_implementation.keys():
+ if event_request_type not in request_implementation:
Committable suggestion was skipped due to low confidence.
bot_settings = MongoProcessor.get_bot_settings(self.bot, self.user) | ||
config = MessageBroadcastProcessor.get_settings(event_id, self.bot, is_resend=True) | ||
|
||
if bot_settings['retry_broadcasting_limit'] <= config["retry_count"]: |
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.
Replace deprecated typing.Text
with str
.
The Text
type is deprecated and should be replaced with str
.
- def execute(self, event_id: Text, **kwargs):
+ def execute(self, event_id: str, **kwargs):
Committable suggestion was skipped due to low confidence.
@@ -99,6 +112,16 @@ | |||
MessageBroadcastProcessor.delete_task(msg_broadcast_id, self.bot) | |||
raise AppException(e) | |||
|
|||
def _resend_broadcast(self, msg_broadcast_id: Text): |
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.
Replace deprecated typing.Text
with str
.
The Text
type is deprecated and should be replaced with str
.
- def _resend_broadcast(self, msg_broadcast_id: Text):
+ def _resend_broadcast(self, msg_broadcast_id: str):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def _resend_broadcast(self, msg_broadcast_id: Text): | |
def _resend_broadcast(self, msg_broadcast_id: str): |
Tools
Ruff
115-115:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
@router.post("/broadcast/message/resend/{msg_broadcast_id}", response_model=Response) | ||
async def resend_message_broadcast_event( | ||
msg_broadcast_id: str, | ||
current_user: User = Security(Authentication.get_current_user_and_bot, scopes=DESIGNER_ACCESS) |
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.
Avoid function call in argument defaults.
Do not perform function call Security
in argument defaults; instead, perform the call within the function or read the default from a module-level singleton variable.
- current_user: User = Security(Authentication.get_current_user_and_bot, scopes=DESIGNER_ACCESS)
+ current_user: User = Depends(lambda: Authentication.get_current_user_and_bot(scopes=DESIGNER_ACCESS))
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
current_user: User = Security(Authentication.get_current_user_and_bot, scopes=DESIGNER_ACCESS) | |
current_user: User = Depends(lambda: Authentication.get_current_user_and_bot(scopes=DESIGNER_ACCESS)) |
Tools
Ruff
188-188: Do not perform function call
Security
in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
def get_settings(notification_id: Text, bot: Text, **kwargs): | ||
try: | ||
settings = MessageBroadcastSettings.objects(id=notification_id, bot=bot, status=True).get() | ||
status = not kwargs.get("is_resend", False) | ||
settings = MessageBroadcastSettings.objects(id=notification_id, bot=bot, status=status).get() |
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.
Replace deprecated Text
with str
.
The Text
type from the typing
module is deprecated. Replace it with str
.
- def get_settings(notification_id: Text, bot: Text, **kwargs):
+ def get_settings(notification_id: str, bot: str, **kwargs):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def get_settings(notification_id: Text, bot: Text, **kwargs): | |
try: | |
settings = MessageBroadcastSettings.objects(id=notification_id, bot=bot, status=True).get() | |
status = not kwargs.get("is_resend", False) | |
settings = MessageBroadcastSettings.objects(id=notification_id, bot=bot, status=status).get() | |
def get_settings(notification_id: str, bot: str, **kwargs): | |
try: | |
status = not kwargs.get("is_resend", False) | |
settings = MessageBroadcastSettings.objects(id=notification_id, bot=bot, status=status).get() |
Tools
Ruff
21-21:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
21-21:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
def extract_message_ids_from_broadcast_logs(reference_id: Text, retry_count: int = 0): | ||
log_type = MessageBroadcastLogType.resend.value if retry_count > 0 else MessageBroadcastLogType.send.value | ||
message_broadcast_logs = MessageBroadcastLogs.objects(reference_id=reference_id, | ||
log_type=MessageBroadcastLogType.send.value) | ||
log_type=log_type, | ||
retry_count=retry_count) | ||
|
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.
Replace deprecated Text
with str
.
The Text
type from the typing
module is deprecated. Replace it with str
.
- def extract_message_ids_from_broadcast_logs(reference_id: Text, retry_count: int = 0):
+ def extract_message_ids_from_broadcast_logs(reference_id: str, retry_count: int = 0):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def extract_message_ids_from_broadcast_logs(reference_id: Text, retry_count: int = 0): | |
log_type = MessageBroadcastLogType.resend.value if retry_count > 0 else MessageBroadcastLogType.send.value | |
message_broadcast_logs = MessageBroadcastLogs.objects(reference_id=reference_id, | |
log_type=MessageBroadcastLogType.send.value) | |
log_type=log_type, | |
retry_count=retry_count) | |
def extract_message_ids_from_broadcast_logs(reference_id: str, retry_count: int = 0): | |
log_type = MessageBroadcastLogType.resend.value if retry_count > 0 else MessageBroadcastLogType.send.value | |
message_broadcast_logs = MessageBroadcastLogs.objects(reference_id=reference_id, | |
log_type=log_type, | |
retry_count=retry_count) |
Tools
Ruff
121-121:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
def add_event_log(bot: Text, log_type: Text, reference_id: Text = None, status: Text = None, **kwargs): | ||
event_completion_states = [EVENT_STATUS.FAIL.value, EVENT_STATUS.COMPLETED.value] | ||
is_new_log = log_type in {MessageBroadcastLogType.send.value, MessageBroadcastLogType.self.value} or kwargs.pop("is_new_log", None) | ||
is_resend = kwargs.pop("is_resend", False) | ||
event_completion_states = [] if is_resend else [EVENT_STATUS.FAIL.value, EVENT_STATUS.COMPLETED.value] | ||
is_new_log = log_type in {MessageBroadcastLogType.send.value, | ||
MessageBroadcastLogType.resend.value, | ||
MessageBroadcastLogType.self.value} or kwargs.pop("is_new_log", None) |
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.
Replace deprecated Text
with str
.
The Text
type from the typing
module is deprecated. Replace it with str
.
- def add_event_log(bot: Text, log_type: Text, reference_id: Text = None, status: Text = None, **kwargs):
+ def add_event_log(bot: str, log_type: str, reference_id: str = None, status: str = None, **kwargs):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def add_event_log(bot: Text, log_type: Text, reference_id: Text = None, status: Text = None, **kwargs): | |
event_completion_states = [EVENT_STATUS.FAIL.value, EVENT_STATUS.COMPLETED.value] | |
is_new_log = log_type in {MessageBroadcastLogType.send.value, MessageBroadcastLogType.self.value} or kwargs.pop("is_new_log", None) | |
is_resend = kwargs.pop("is_resend", False) | |
event_completion_states = [] if is_resend else [EVENT_STATUS.FAIL.value, EVENT_STATUS.COMPLETED.value] | |
is_new_log = log_type in {MessageBroadcastLogType.send.value, | |
MessageBroadcastLogType.resend.value, | |
MessageBroadcastLogType.self.value} or kwargs.pop("is_new_log", None) | |
def add_event_log(bot: str, log_type: str, reference_id: str = None, status: str = None, **kwargs): | |
is_resend = kwargs.pop("is_resend", False) | |
event_completion_states = [] if is_resend else [EVENT_STATUS.FAIL.value, EVENT_STATUS.COMPLETED.value] | |
is_new_log = log_type in {MessageBroadcastLogType.send.value, | |
MessageBroadcastLogType.resend.value, | |
MessageBroadcastLogType.self.value} or kwargs.pop("is_new_log", None) |
Tools
Ruff
84-84:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
84-84:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
84-84:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
84-84:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
def update_retry_count(notification_id: Text, bot: Text, user: Text, retry_count: int = 0): | ||
try: | ||
settings = MessageBroadcastSettings.objects(id=notification_id, bot=bot, status=False).get() | ||
settings.retry_count = retry_count | ||
settings.user = user | ||
settings.timestamp = datetime.utcnow() | ||
settings.save() | ||
return settings.to_mongo().to_dict() |
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.
Replace deprecated Text
with str
.
The Text
type from the typing
module is deprecated. Replace it with str
.
- def update_retry_count(notification_id: Text, bot: Text, user: Text, retry_count: int = 0):
+ def update_retry_count(notification_id: str, bot: str, user: str, retry_count: int = 0):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def update_retry_count(notification_id: Text, bot: Text, user: Text, retry_count: int = 0): | |
try: | |
settings = MessageBroadcastSettings.objects(id=notification_id, bot=bot, status=False).get() | |
settings.retry_count = retry_count | |
settings.user = user | |
settings.timestamp = datetime.utcnow() | |
settings.save() | |
return settings.to_mongo().to_dict() | |
def update_retry_count(notification_id: str, bot: str, user: str, retry_count: int = 0): | |
try: | |
settings = MessageBroadcastSettings.objects(id=notification_id, bot=bot, status=False).get() | |
settings.retry_count = retry_count | |
settings.user = user | |
settings.timestamp = datetime.utcnow() | |
settings.save() | |
return settings.to_mongo().to_dict() |
Tools
Ruff
188-188:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
188-188:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
188-188:
typing.Text
is deprecated, usestr
Replace with
str
(UP019)
Added code related to Resend Broadcast.
Fixed and added test cases related to the same.
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Configuration
system.yaml
to include new error codes for360Dialog
configuration.Documentation