@@ -17,19 +17,21 @@ class CovidcastRow():
17
17
"""A container for all the values of a single covidcast row."""
18
18
19
19
@staticmethod
20
- def fromCsvRowValue (row_value , source , signal , time_type , geo_type , time_value ):
20
+ def fromCsvRowValue (row_value , source , signal , time_type , geo_type , time_value , issue , lag ):
21
21
return CovidcastRow (source , signal , time_type , geo_type , time_value ,
22
- row_value .geo_value ,
23
- row_value .value ,
24
- row_value .stderr ,
25
- row_value .sample_size )
22
+ row_value .geo_value ,
23
+ row_value .value ,
24
+ row_value .stderr ,
25
+ row_value .sample_size ,
26
+ issue , lag )
26
27
27
28
@staticmethod
28
- def fromCsvRows (row_values , source , signal , time_type , geo_type , time_value ):
29
+ def fromCsvRows (row_values , source , signal , time_type , geo_type , time_value , issue , lag ):
29
30
# NOTE: returns a generator, as row_values is expected to be a generator
30
- return (CovidcastRow .fromCsvRowValue (row_value , source , signal , time_type , geo_type , time_value ) for row_value in row_values )
31
+ return (CovidcastRow .fromCsvRowValue (row_value , source , signal , time_type , geo_type , time_value , issue , lag )
32
+ for row_value in row_values )
31
33
32
- def __init__ (self , source , signal , time_type , geo_type , time_value , geo_value , value , stderr , sample_size ):
34
+ def __init__ (self , source , signal , time_type , geo_type , time_value , geo_value , value , stderr , sample_size , issue , lag ):
33
35
self .id = None
34
36
self .source = source
35
37
self .signal = signal
@@ -42,6 +44,8 @@ def __init__(self, source, signal, time_type, geo_type, time_value, geo_value, v
42
44
self .sample_size = sample_size # from CSV row
43
45
self .timestamp2 = 0
44
46
self .direction = None
47
+ self .issue = issue
48
+ self .lag = lag
45
49
46
50
47
51
class Database :
@@ -98,11 +102,13 @@ def insert_or_update_batch(self, cc_rows, batch_size=0, commit_partial=False):
98
102
INSERT INTO `covidcast`
99
103
(`id`, `source`, `signal`, `time_type`, `geo_type`, `time_value`, `geo_value`,
100
104
`timestamp1`, `value`, `stderr`, `sample_size`,
101
- `timestamp2`, `direction`)
105
+ `timestamp2`, `direction`,
106
+ `issue`, `lag`)
102
107
VALUES
103
108
(0, %s, %s, %s, %s, %s, %s,
104
109
UNIX_TIMESTAMP(NOW()), %s, %s, %s,
105
- 0, NULL)
110
+ 0, NULL,
111
+ %s, %s)
106
112
ON DUPLICATE KEY UPDATE
107
113
`timestamp1` = VALUES(`timestamp1`),
108
114
`value` = VALUES(`value`),
@@ -132,6 +138,8 @@ def insert_or_update_batch(self, cc_rows, batch_size=0, commit_partial=False):
132
138
row .value ,
133
139
row .stderr ,
134
140
row .sample_size ,
141
+ row .issue ,
142
+ row .lag
135
143
) for row in cc_rows [start :end ]]
136
144
137
145
result = self ._cursor .executemany (sql , args )
0 commit comments