Sourcery refactored main branch#1
Open
sourcery-ai[bot] wants to merge 1 commit into
Open
Conversation
Comment on lines
-14
to
+18
| appln_id = request.env['onesignal.credentials'].sudo().search([('is_active','=',True)]) | ||
| if appln_id: | ||
| if ( | ||
| appln_id := request.env['onesignal.credentials'] | ||
| .sudo() | ||
| .search([('is_active', '=', True)]) | ||
| ): |
Author
There was a problem hiding this comment.
Function ActiveAppCtrl.check_active_app refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
| #STEP 1 : CHECK IF BOOLEAN ACTIVE IN OTHER APP | ||
| app_ids = self.search([('is_active','=',True)]) | ||
| if app_ids: | ||
| if app_ids := self.search([('is_active', '=', True)]): |
Author
There was a problem hiding this comment.
Function OnesignalCredentials.activate_app refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
This removes the following comments ( why? ):
#STEP 1 : CHECK IF BOOLEAN ACTIVE IN OTHER APP
Comment on lines
-41
to
+44
| header = {"Content-Type": "application/json; charset=utf-8", | ||
| "Authorization": "Basic {}".format(app.apikey)} | ||
| header = { | ||
| "Content-Type": "application/json; charset=utf-8", | ||
| "Authorization": f"Basic {app.apikey}", | ||
| } |
Author
There was a problem hiding this comment.
Function OnesignalMessage.get_app_data refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
Comment on lines
-60
to
+83
|
|
||
| payload = {"app_id": "{}".format(appln_data.get('app_id')), | ||
| "included_segments": ["All"], | ||
| "contents": {"en": "{}".format(message_content)}, | ||
| "headings" :{"en": "{}".format(message_title)}, | ||
| "url": "{}".format(self.launch_url), | ||
| "chrome_web_icon": "{}".format(self.icon), | ||
| "ttl": self.time_to_live or 3, | ||
| } | ||
|
|
||
| payload = { | ||
| "app_id": f"{appln_data.get('app_id')}", | ||
| "included_segments": ["All"], | ||
| "contents": {"en": f"{message_content}"}, | ||
| "headings": {"en": f"{message_title}"}, | ||
| "url": f"{self.launch_url}", | ||
| "chrome_web_icon": f"{self.icon}", | ||
| "ttl": self.time_to_live or 3, | ||
| } | ||
| if self.priority: | ||
| priority = self.get_key(var,self.priority) | ||
| payload.update({ | ||
| 'priority':priority | ||
| }) | ||
| payload['priority'] = priority | ||
| if self.send_to_chrome or self.send_to_mozilla or self.send_to_edge: | ||
| payload.update({ | ||
| 'isAnyWeb': True | ||
| }) | ||
| payload['isAnyWeb'] = True | ||
| try: | ||
| response = requests.post("https://onesignal.com/api/v1/notifications", headers=header, data=json.dumps(payload)) | ||
| if response.status_code == 200: | ||
| resp = response.json() | ||
| self.summary = "RECEIPIENTS : {}".format(resp.get('recipients')) | ||
| self.summary = f"RECEIPIENTS : {resp.get('recipients')}" | ||
| else: | ||
| self.summary = "Error : {}".format(response.text) | ||
| self.summary = f"Error : {response.text}" |
Author
There was a problem hiding this comment.
Function OnesignalMessage.send_push_notification refactored with the following changes:
- Replace call to format with f-string [×7] (
use-fstring-for-formatting) - Add single value to dictionary directly rather than using update() [×2] (
simplify-dictionary-update)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branch
mainrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
mainbranch, then run:Help us improve this pull request!