@@ -42,7 +42,7 @@ def __init__(self, source, signal, time_type, geo_type, time_value, geo_value, v
42
42
self .value = value # ...
43
43
self .stderr = stderr # ...
44
44
self .sample_size = sample_size # from CSV row
45
- self .timestamp2 = 0
45
+ self .direction_updated_timestamp = 0
46
46
self .direction = None
47
47
self .issue = issue
48
48
self .lag = lag
@@ -101,21 +101,21 @@ def insert_or_update_batch(self, cc_rows, batch_size=0, commit_partial=False):
101
101
sql = '''
102
102
INSERT INTO `covidcast`
103
103
(`id`, `source`, `signal`, `time_type`, `geo_type`, `time_value`, `geo_value`,
104
- `timestamp1 `, `value`, `stderr`, `sample_size`,
105
- `timestamp2 `, `direction`,
104
+ `value_updated_timestamp `, `value`, `stderr`, `sample_size`,
105
+ `direction_updated_timestamp `, `direction`,
106
106
`issue`, `lag`)
107
107
VALUES
108
108
(0, %s, %s, %s, %s, %s, %s,
109
109
UNIX_TIMESTAMP(NOW()), %s, %s, %s,
110
110
0, NULL,
111
111
%s, %s)
112
112
ON DUPLICATE KEY UPDATE
113
- `timestamp1 ` = VALUES(`timestamp1 `),
113
+ `value_updated_timestamp ` = VALUES(`value_updated_timestamp `),
114
114
`value` = VALUES(`value`),
115
115
`stderr` = VALUES(`stderr`),
116
116
`sample_size` = VALUES(`sample_size`)
117
117
'''
118
- # TODO: ^ do we want to reset `timestamp2 ` and `direction` in the duplicate key case?
118
+ # TODO: ^ do we want to reset `direction_updated_timestamp ` and `direction` in the duplicate key case?
119
119
120
120
# TODO: consider handling cc_rows as a generator instead of a list
121
121
num_rows = len (cc_rows )
@@ -175,7 +175,7 @@ def insert_or_update(
175
175
INSERT INTO `covidcast` VALUES
176
176
(0, %s, %s, %s, %s, %s, %s, UNIX_TIMESTAMP(NOW()), %s, %s, %s, 0, NULL, %s, %s)
177
177
ON DUPLICATE KEY UPDATE
178
- `timestamp1 ` = VALUES(`timestamp1 `),
178
+ `value_updated_timestamp ` = VALUES(`value_updated_timestamp `),
179
179
`value` = VALUES(`value`),
180
180
`stderr` = VALUES(`stderr`),
181
181
`sample_size` = VALUES(`sample_size`)
@@ -246,7 +246,7 @@ def update_direction(
246
246
UPDATE
247
247
`covidcast`
248
248
SET
249
- `timestamp2 ` = UNIX_TIMESTAMP(NOW()),
249
+ `direction_updated_timestamp ` = UNIX_TIMESTAMP(NOW()),
250
250
`direction` = %s
251
251
WHERE
252
252
`source` = %s AND
@@ -286,9 +286,9 @@ def get_all_record_values_of_timeseries_with_potentially_stale_direction(self, t
286
286
`geo_type` varchar(12),
287
287
`geo_value` varchar(12),
288
288
`time_value` int(11),
289
- `timestamp1 ` int(11),
289
+ `value_updated_timestamp ` int(11),
290
290
`value` double,
291
- `timestamp2 ` int(11),
291
+ `direction_updated_timestamp ` int(11),
292
292
`direction` int(11),
293
293
PRIMARY KEY(`id`)
294
294
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -305,9 +305,9 @@ def get_all_record_values_of_timeseries_with_potentially_stale_direction(self, t
305
305
`geo_type`,
306
306
`geo_value`,
307
307
`time_value`,
308
- `timestamp1 `,
308
+ `value_updated_timestamp `,
309
309
`value`,
310
- `timestamp2 `,
310
+ `direction_updated_timestamp `,
311
311
`direction`
312
312
FROM
313
313
(
@@ -358,7 +358,7 @@ def get_all_record_values_of_timeseries_with_potentially_stale_direction(self, t
358
358
`geo_type`,
359
359
`geo_value`
360
360
HAVING
361
- MAX(`timestamp1 `) > MIN(`timestamp2 `)
361
+ MAX(`value_updated_timestamp `) > MIN(`direction_updated_timestamp `)
362
362
'''
363
363
364
364
# A query that selects rows of the time-series selected by stale_ts_key_sql query.
@@ -372,9 +372,9 @@ def get_all_record_values_of_timeseries_with_potentially_stale_direction(self, t
372
372
`geo_type`,
373
373
`geo_value`,
374
374
`time_value`,
375
- `timestamp1 `,
375
+ `value_updated_timestamp `,
376
376
`value`,
377
- `timestamp2 `,
377
+ `direction_updated_timestamp `,
378
378
`direction`
379
379
FROM ({ stale_ts_key_sql } ) AS t2
380
380
LEFT JOIN `latest_issues` AS t3
@@ -424,8 +424,8 @@ def drop_temporary_table(self, tmp_table_name):
424
424
sql = f'DROP TEMPORARY TABLE `{ tmp_table_name } `;'
425
425
self ._cursor .execute (sql )
426
426
427
- def update_timestamp2_from_temporary_table (self , tmp_table_name ):
428
- """Updates the `timestamp2 ` column of `covidcast` table for all the rows with id value in `tmp_table_name`.
427
+ def update_direction_updated_timestamp_from_temporary_table (self , tmp_table_name ):
428
+ """Updates the `direction_updated_timestamp ` column of `covidcast` table for all the rows with id value in `tmp_table_name`.
429
429
430
430
`tmp_table_name`: name of the temporary table.
431
431
"""
@@ -437,7 +437,7 @@ def update_timestamp2_from_temporary_table(self, tmp_table_name):
437
437
ON
438
438
`covidcast`.id=t.id
439
439
SET
440
- `covidcast`.timestamp2 =UNIX_TIMESTAMP(NOW())
440
+ `covidcast`.direction_updated_timestamp =UNIX_TIMESTAMP(NOW())
441
441
'''
442
442
self ._cursor .execute (sql )
443
443
@@ -457,8 +457,8 @@ def get_keys_with_potentially_stale_direction(self):
457
457
`signal`,
458
458
`geo_type`,
459
459
`geo_value`,
460
- MAX(`timestamp1 `) AS `max_timestamp1 `,
461
- MIN(`timestamp2 `) AS `min_timestamp2 `,
460
+ MAX(`value_updated_timestamp `) AS `max_value_updated_timestamp `,
461
+ MIN(`direction_updated_timestamp `) AS `min_direction_updated_timestamp `,
462
462
MIN(`time_value`) AS `min_day`,
463
463
MAX(`time_value`) AS `max_day`,
464
464
COUNT(1) AS `series_length`
@@ -473,7 +473,7 @@ def get_keys_with_potentially_stale_direction(self):
473
473
`geo_type`,
474
474
`geo_value`
475
475
HAVING
476
- MAX(`timestamp1 `) > MIN(`timestamp2 `)
476
+ MAX(`value_updated_timestamp `) > MIN(`direction_updated_timestamp `)
477
477
'''
478
478
479
479
self ._cursor .execute (sql )
@@ -488,8 +488,8 @@ def get_daily_timeseries_for_direction_update(
488
488
DATEDIFF(`time_value`, %s) AS `offset`,
489
489
`time_value` AS `day`,
490
490
`value`,
491
- `timestamp1 `,
492
- `timestamp2 `
491
+ `value_updated_timestamp `,
492
+ `direction_updated_timestamp `
493
493
FROM
494
494
`covidcast`
495
495
WHERE
@@ -507,9 +507,9 @@ def get_daily_timeseries_for_direction_update(
507
507
self ._cursor .execute (sql , args )
508
508
return list (self ._cursor )
509
509
510
- def update_timeseries_timestamp2 (
510
+ def update_timeseries_direction_updated_timestamp (
511
511
self , source , signal , time_type , geo_type , geo_value ):
512
- """Update the `timestamp2 ` column for an entire time-series.
512
+ """Update the `direction_updated_timestamp ` column for an entire time-series.
513
513
514
514
For daily time-series, this implies that all `direction` values in the
515
515
specified time-series are confirmed fresh as of the current time. Even if
@@ -523,7 +523,7 @@ def update_timeseries_timestamp2(
523
523
UPDATE
524
524
`covidcast`
525
525
SET
526
- `timestamp2 ` = UNIX_TIMESTAMP(NOW())
526
+ `direction_updated_timestamp ` = UNIX_TIMESTAMP(NOW())
527
527
WHERE
528
528
`source` = %s AND
529
529
`signal` = %s AND
@@ -552,7 +552,7 @@ def get_covidcast_meta(self):
552
552
MAX(`value`) AS `max_value`,
553
553
ROUND(AVG(`value`),7) AS `mean_value`,
554
554
ROUND(STD(`value`),7) AS `stdev_value`,
555
- MAX(`timestamp1 `) AS `last_update`,
555
+ MAX(`value_updated_timestamp `) AS `last_update`,
556
556
MAX(`issue`) as `max_issue`,
557
557
MIN(`lag`) as `min_lag`,
558
558
MAX(`lag`) as `max_lag`
0 commit comments