Project

General

Profile

0004-feeder-add-timetamp-version-of-receipt_time.patch

Benjamin Dauvergne, 24 Sep 2019 03:28 PM

Download (2.24 KB)

View differences:

Subject: [PATCH 4/7] feeder: add timetamp version of receipt_time

 tests/test_wcs.py  | 2 ++
 wcs_olap/feeder.py | 3 +++
 2 files changed, 5 insertions(+)
tests/test_wcs.py
36 36
        ('formdata', 'id'),
37 37
        ('formdata', 'formdef_id'),
38 38
        ('formdata', 'receipt_time'),
39
        ('formdata', 'receipt_time2'),
39 40
        ('formdata', 'hour_id'),
40 41
        ('formdata', 'channel_id'),
41 42
        ('formdata', 'backoffice'),
......
47 48
        ('formdata_demande', 'id'),
48 49
        ('formdata_demande', 'formdef_id'),
49 50
        ('formdata_demande', 'receipt_time'),
51
        ('formdata_demande', 'receipt_time2'),
50 52
        ('formdata_demande', 'hour_id'),
51 53
        ('formdata_demande', 'channel_id'),
52 54
        ('formdata_demande', 'backoffice'),
wcs_olap/feeder.py
468 468
            ['id', 'serial primary key'],
469 469
            ['formdef_id', 'smallint REFERENCES {form_table} (id)'],
470 470
            ['receipt_time', 'date'],
471
            ['receipt_time2', 'timestamp'],
471 472
            ['hour_id', 'smallint REFERENCES {hour_table} (id)'],
472 473
            ['channel_id', 'smallint REFERENCES {channel_table} (id)'],
473 474
            ['backoffice', 'boolean'],
......
756 757
            row = {
757 758
                'formdef_id': self.formdef_sql_id,
758 759
                'receipt_time': data.receipt_time,
760
                # anonymise a little the timestamp by truncating precision to hour
761
                'receipt_time2': data.receipt_time.replace(minute=0, second=0, microsecond=0),
759 762
                'hour_id': data.receipt_time.hour,
760 763
                'channel_id': self.channel_to_id[channel],
761 764
                'backoffice': data.submission.backoffice,
762
-