Humanize last comment datetime (#342)

This commit is contained in:
calixteman 2019-02-04 19:02:51 +01:00 коммит произвёл Sylvestre Ledru
Родитель f1c4ea1bdf
Коммит 50442d1201
2 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -3,11 +3,14 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
import argparse
from datetime import datetime
import dateutil.parser
from dateutil.relativedelta import relativedelta
import humanize
from jinja2 import Environment, FileSystemLoader
from libmozdata.bugzilla import Bugzilla
from libmozdata import utils as lmdutils
import pytz
import six
from auto_nag import mail, utils
from auto_nag.nag_me import Nag
@ -293,9 +296,9 @@ class BzCleaner(object):
if self.has_last_comment_time():
if comments:
# get the timestamp of the last comment
self.last_comment[bugid] = dateutil.parser.parse(
comments[-1]['time']
).strftime('%Y-%m-%d %H:%M:%S')
today = pytz.utc.localize(datetime.utcnow())
dt = dateutil.parser.parse(comments[-1]['time'])
self.last_comment[bugid] = humanize.naturaldelta(today - dt)
else:
self.last_comment[bugid] = ''

Просмотреть файл

@ -3,6 +3,7 @@ argparse==1.2.1
certifi>=2017.4.17
chardet<3.1.0,>=3.0.2
httplib2>=0.9.1
humanize>=0.5.1
libmozdata>=0.1.47
path.py==2.2.2
pep8==0.6.1
@ -12,5 +13,6 @@ remoteobjects
requests>=2.20.0
pexpect==3.1
python-Levenshtein>=0.12.0
pytz>=2018.9
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz#egg=en-core-web-sm
https://github.com/marco-c/bugbug/archive/0f78f2b77aacd44caf89b3e2b3b5f869266e472e.tar.gz#egg=bugbug