wikimedia / WikiContrib

A tool for Wikimedia community members to visualize their technical contributions
https://wikicontrib.toolforge.org
MIT License
23 stars 32 forks source link

fixed all datetime related bugs ---- #123 #102 #21 --- Patch #217

Closed NdibeRaymond closed 4 years ago

NdibeRaymond commented 4 years ago

Parent PR : #200 Issue fixed : #21

NdibeRaymond commented 4 years ago

@NdibeRaymond I think this PR mostly solves the issue, but I am running into another while testing, which might be unrelated (see below). I am not getting this error when trying to visualize contributions of users I have not inputted before, but otherwise, I get the error. I am guessing I need to delete queries from somewhere. If so, could you share the instructions so that I can give it one more shot?

backend-end_1  | [12/Jul/2020 00:06:39] "GET /query/ed84qjacjJEQ2BhLoAXDJFQgmsy0QhmLHYsbJpSUzl7G9Bb1HWwZ9CpV7unR4ep6/update/user/ HTTP/1.1" 200 159
backend-end_1  | [12/Jul/2020 00:06:51] "OPTIONS /query/ed84qjacjJEQ2BhLoAXDJFQgmsy0QhmLHYsbJpSUzl7G9Bb1HWwZ9CpV7unR4ep6/update/user/ HTTP/1.1" 200 0
backend-end_1  | [12/Jul/2020 00:06:51] "PATCH /query/ed84qjacjJEQ2BhLoAXDJFQgmsy0QhmLHYsbJpSUzl7G9Bb1HWwZ9CpV7unR4ep6/update/user/ HTTP/1.1" 303 0
backend-end_1  | 1.7887871265411377
backend-end_1  | Internal Server Error: /result/ed84qjacjJEQ2BhLoAXDJFQgmsy0QhmLHYsbJpSUzl7G9Bb1HWwZ9CpV7unR4ep6/
backend-end_1  | Traceback (most recent call last):
backend-end_1  |   File "/code/result/views.py", line 413, in format_data
backend-end_1  |     ghd[i]['commit']['committer']['date'],"%Y-%m-%dT%H:%M:%S.%f%z")
backend-end_1  |   File "/usr/local/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
backend-end_1  |     tt, fraction = _strptime(data_string, format)
backend-end_1  |   File "/usr/local/lib/python3.6/_strptime.py", line 362, in _strptime
backend-end_1  |     (data_string, format))
backend-end_1  | ValueError: time data '2019-09-23T17:28:02.000-07:00' does not match format '%Y-%m-%dT%H:%M:%S.%f%z'
backend-end_1  | 
backend-end_1  | During handling of the above exception, another exception occurred:
backend-end_1  | 
backend-end_1  | Traceback (most recent call last):
backend-end_1  |   File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
backend-end_1  |     response = get_response(request)
backend-end_1  |   File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
backend-end_1  |     response = self.process_exception_by_middleware(e, request)
backend-end_1  |   File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
backend-end_1  |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
backend-end_1  |   File "/usr/local/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
backend-end_1  |     return view_func(*args, **kwargs)
backend-end_1  |   File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 71, in view
backend-end_1  |     return self.dispatch(request, *args, **kwargs)
backend-end_1  |   File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 495, in dispatch
backend-end_1  |     response = self.handle_exception(exc)
backend-end_1  |   File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 455, in handle_exception
backend-end_1  |     self.raise_uncaught_exception(exc)
backend-end_1  |   File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 492, in dispatch
backend-end_1  |     response = handler(request, *args, **kwargs)
backend-end_1  |   File "/code/result/views.py", line 679, in get
backend-end_1  |     createdEnd=createdEnd, phid=phid, query=query, users=paginate)
backend-end_1  |   File "/code/result/views.py", line 544, in getDetails
backend-end_1  |     github_rate_limit_message, query, phid[0])
backend-end_1  |   File "/code/result/views.py", line 452, in format_data
backend-end_1  |     ghd_rate_limit_message[0] = ghd[i]['rate-limit-message']
backend-end_1  | KeyError: 'rate-limit-message'
backend-end_1  | [12/Jul/2020 00:06:54] "GET /result/ed84qjacjJEQ2BhLoAXDJFQgmsy0QhmLHYsbJpSUzl7G9Bb1HWwZ9CpV7unR4ep6/ HTTP/1.1" 500 15179

This error seems to be linux only issue as i don't experience this on my local machine. But given that our backend runs on linux, it is safe to assume this might come up in production. I am looking it this now to find out why this is happening.

To delete all saved queries on your local machine:

And also you might need to run python manage.py makemigrations and python manage.py migrate after

Update

@srish after trying to figure out why this error occurs on your machine but not on mine, i found out you are using python3.6. Github is returning datetime string in a format that python3.6 can't handle. Only newer python versions like 3.7 and 3.8 can work here. This means you need to update your python version

rammanoj commented 4 years ago

@srish any update on this. Have you checked it with the latest version? , the basic functioning worked good to me.