[hooks] fix timestamp confusion in DataImportsCleanupStartupHook
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 09 Dec 2015 14:06:43 +0100
changeset 10962 625b951b4a1a
parent 10961 6ff786884aad
child 10963 9b1c7f337eb3
[hooks] fix timestamp confusion in DataImportsCleanupStartupHook CWDataImport.start_timestamp is inserted as datetime.utcnow(), in server/sources/datafeed.py:DataFeedSourceinit_import_log. Don't compare it to datetime.now().
hooks/__init__.py
--- a/hooks/__init__.py	Wed Dec 09 13:58:03 2015 +0100
+++ b/hooks/__init__.py	Wed Dec 09 14:06:43 2015 +0100
@@ -77,7 +77,7 @@
                     or not repo.config.source_enabled(source)):
                     continue
                 with repo.internal_cnx() as cnx:
-                    mindate = datetime.now() - timedelta(seconds=source.config['logs-lifetime'])
+                    mindate = datetime.utcnow() - timedelta(seconds=source.config['logs-lifetime'])
                     cnx.execute('DELETE CWDataImport X WHERE X start_timestamp < %(time)s',
                                     {'time': mindate})
                     cnx.commit()