feeder: add timetamp version of receipt_time

This commit is contained in:
Benjamin Dauvergne 2019-01-18 22:44:24 +01:00
parent 83c9d7adaf
commit 568cfad036
2 changed files with 5 additions and 0 deletions

View File

@ -36,6 +36,7 @@ def test_wcs_fixture(wcs, postgres_db, tmpdir, olap_cmd, caplog):
('formdata', 'id'),
('formdata', 'formdef_id'),
('formdata', 'receipt_time'),
('formdata', 'receipt_time2'),
('formdata', 'hour_id'),
('formdata', 'channel_id'),
('formdata', 'backoffice'),
@ -47,6 +48,7 @@ def test_wcs_fixture(wcs, postgres_db, tmpdir, olap_cmd, caplog):
('formdata_demande', 'id'),
('formdata_demande', 'formdef_id'),
('formdata_demande', 'receipt_time'),
('formdata_demande', 'receipt_time2'),
('formdata_demande', 'hour_id'),
('formdata_demande', 'channel_id'),
('formdata_demande', 'backoffice'),

View File

@ -468,6 +468,7 @@ CREATE TABLE public.dates AS (SELECT
['id', 'serial primary key'],
['formdef_id', 'smallint REFERENCES {form_table} (id)'],
['receipt_time', 'date'],
['receipt_time2', 'timestamp'],
['hour_id', 'smallint REFERENCES {hour_table} (id)'],
['channel_id', 'smallint REFERENCES {channel_table} (id)'],
['backoffice', 'boolean'],
@ -756,6 +757,8 @@ class WcsFormdefFeeder(object):
row = {
'formdef_id': self.formdef_sql_id,
'receipt_time': data.receipt_time,
# anonymise a little the timestamp by truncating precision to hour
'receipt_time2': data.receipt_time.replace(minute=0, second=0, microsecond=0),
'hour_id': data.receipt_time.hour,
'channel_id': self.channel_to_id[channel],
'backoffice': data.submission.backoffice,