Skip to content

Rendering and notification field#14

Merged
sonus21 merged 15 commits into
sonus21:masterfrom
tboulogne:master
Oct 21, 2020
Merged

Rendering and notification field#14
sonus21 merged 15 commits into
sonus21:masterfrom
tboulogne:master

Conversation

@tboulogne

Copy link
Copy Markdown
Contributor

Hello,

Thanks for your works. With this pull, i'd like to contribute with :

  • switch to bootstrap 4
  • two new fields (notification_send, ticket_raised) to avoid multiple notifications or tickets for same error
  • prettify of request_data
    image
  • new rendering of details and list (bootstrap 4)
    image
  • two new blocks : head_script and header_block in template

Feel free to accept what you want.

Regards

Thierry

notification_send > for notification
ticket_raise > for ticket creation
Check if a ticket already raised or notification send before sending
- add head_script block for extending script and css
- add header_block
- refactor detail template
- refactor list template
- ad pre tag to prettify request_data and exception detail view
@sonus21

sonus21 commented Oct 19, 2020

Copy link
Copy Markdown
Owner

Just a high level comment from me,
We should take notification send as an additional configuration, some users might want to send notifications for subsequent failures as well but other might not be like you.

Even when we're not sending notifications, we should consider the time difference between two consecutive failures. If we're seeing time difference is greater than some delta than we should send notification, reason for this is we keep overriding the failure, that does not mean yesterday failure is same as today's failure, it could be as well but we're not sure only developer has the right knowledge about such things.

@tboulogne

tboulogne commented Oct 19, 2020 via email

Copy link
Copy Markdown
Contributor Author

@tboulogne

Copy link
Copy Markdown
Contributor Author

@sonus21 add parameter for notification and ticket.

@@ -0,0 +1,28 @@
# Generated by Django 3.1.2 on 2020-10-18 11:17

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We don't need this file

]

operations = [
# migrations.AddField(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We would need to add migrations for exceptions table. And please remove alter for request_data field.

@tboulogne

Copy link
Copy Markdown
Contributor Author

@sonus21 let me know if better now.

Comment thread error_tracker/django/utils.py Outdated
try:
headers = request.headers.dict()
except AttributeError:
headers = request.headers

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

maybe you can pull this to another method to pull cookie.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sonus21 don't understand your meaning, could you explain a little bit please ?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

You can add a function that will get cookie from request object.

Comment thread error_tracker/libs/mixins.py Outdated
Comment on lines +42 to +43
notification_send = None
ticket_raised = None

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Default value can be false.

add method to parse cookie
@tboulogne

Copy link
Copy Markdown
Contributor Author

@sonus21 let me know if better now please.

@sonus21 sonus21 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Overall looks good, there're just few nitpicks, once addressed I'll approve and release a new version.

Comment thread error_tracker/django/models.py Outdated
created_on = models.DateTimeField(auto_now=True)
last_seen = models.DateTimeField(auto_now=True, db_index=True)

notification_send = models.BooleanField(default=False)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please rename this to notification_sent

operations = [
migrations.AddField(
model_name='errormodel',
name='notification_send',

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

notification_sent as column name

Comment thread error_tracker/django/settings.py Outdated
# Check error views are visible to others or not
APP_ERROR_VIEW_PERMISSION = get('APP_ERROR_VIEW_PERMISSION', None)
# Send email notification once
APP_ERROR_NOTIFICATION_ONCE = get('APP_ERROR_NOTIFICATION_ONCE', None)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Here default should be False

Comment thread error_tracker/django/settings.py Outdated
# Send email notification once
APP_ERROR_NOTIFICATION_ONCE = get('APP_ERROR_NOTIFICATION_ONCE', None)
# Raise ticket once
APP_ERROR_TICKET_ONCE = get('APP_ERROR_NOTIFICATION_ONCE', None)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

same

for key, value in headers.items():
try:
# Test if value could be json loaded, parse if needed as for cookie.
json.loads('{"%s":"%s"}' % (key, value))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

No usage of json.loads?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Emulate json.loads to detect problematic values and set them to value=""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can you please provide some more details how it helps you and on what value? As you're encoding value in string something like this

{
   "foo" : "<value>"
}

As your code, any value could be parsed.

set APP_ERROR_XXX_ONCE to False
Comment thread error_tracker/django/utils.py Outdated
return x


def cookie_parse(headers):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

One last change request, this method does not seem to parse only cookie, it's parsing header. Can we rename this method to parse_headers

for key, value in headers.items():
try:
# Test if value could be json loaded, parse if needed as for cookie.
json.loads('{"%s":"%s"}' % (key, value))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can you please provide some more details how it helps you and on what value? As you're encoding value in string something like this

{
   "foo" : "<value>"
}

As your code, any value could be parsed.

rename cookie_parse to parse_headers
@tboulogne

Copy link
Copy Markdown
Contributor Author

json.loads('{"%s":"%s"}' % (key, value))

Parse each key, value from headers items and Test if could be "json loaded". If not, we set the correspondant value to empty except for cookie key.

because, if could not load a key, value with json, pretty display will not works...

hope it help you to understand...

Regards

@sonus21

sonus21 commented Oct 20, 2020

Copy link
Copy Markdown
Owner

json.loads('{"%s":"%s"}' % (key, value))

Parse each key, value from headers items and Test if could be "json loaded". If not, we set the correspondant value to empty except for cookie key.

because, if could not load a key, value with json, pretty display will not works...

How are we going to handle form data? I'm still not convinced this will be able to catch the json load error. Can you please share some example request data?

@tboulogne

tboulogne commented Oct 20, 2020

Copy link
Copy Markdown
Contributor Author

@sonus21 could you trust me on this point :-) ? I faced the problem to provide this tortuous solution :-).

@tboulogne

Copy link
Copy Markdown
Contributor Author

json.loads('{"%s":"%s"}' % (key, value))
Parse each key, value from headers items and Test if could be "json loaded". If not, we set the correspondant value to empty except for cookie key.
because, if could not load a key, value with json, pretty display will not works...

How are we going to handle form data? I'm still not convinced this will be able to catch the json load error. Can you please share some example request data?
Something like that

{'headers': {'Host': 'xxxxxxx', 'Accept': 'text/css,*/*;q=0.1', 'Connection': 'keep-alive', 'Cookie': {'sessionid': 'z027lpgvxo3pf85u6pkzsqdcs87cyojr', 'csrftoken': 'XXXXXXXXXXXXXXXXXXXXXXX', 'messages': '__json_message,0,25,Connexion avec myuser r\\u00e9ussie.],[__json_message,0,25,Connexion avec myuser r\\u00e9ussie.],[__json_message,0,25,Connexion avec myuser r\\u00e9ussie.],[__json_message,0,25,Connexion avec myuser r\\u00e9ussie.],[__json_message,0,25,Connexion avec myuser r\\u00e9ussie.],[__json_message,0,25,Connexion avec myuser r\\u00e9ussie.],[__json_message,0,25,Connexion avec myuser r\\u00e9ussie.],[__json_message,0,25,Connexion avec myuser r\\u00e9ussie.],[__json_message,0,25,Connexion avec myuser r\\u00e9ussie.],[__json_message,0,25,Connexion avec myuser r\\u00e9ussie.],[__json_message,0,25,Vous \\u00eates d\\u00e9connect\\u00e9.],[__json_message,0,25,Connexion avec myuser r\\u00e9ussie.:1kUbGk:y1uTcIVlaWEYbyJGMKZ5r5qisGggfuA4L6Pt2kflF4w'}, 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15', 'Accept-Language': 'fr-fr', 'Referer': 'http://127.0.0.1:8000/render_list/products_manager/manageproduct_list/_mp_import_status/ALL/', 'Accept-Encoding': 'gzip, deflate'}}```

@sonus21

sonus21 commented Oct 21, 2020

Copy link
Copy Markdown
Owner

@sonus21 could you trust me on this point :-) ? I faced the problem to provide this tortuous solution :-).

Approved still I need to see.

@sonus21 sonus21 merged commit 20e7c43 into sonus21:master Oct 21, 2020
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.

2 participants