2017-10-04 00:06:53 +00:00
|
|
|
from __future__ import print_function
|
2015-09-06 20:28:20 +00:00
|
|
|
import json
|
|
|
|
from redash import models
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
for vis in models.Visualization.select():
|
|
|
|
if vis.type == 'COUNTER':
|
|
|
|
options = json.loads(vis.options)
|
2017-10-04 00:06:53 +00:00
|
|
|
print("Before: ", options)
|
2015-09-09 06:57:54 +00:00
|
|
|
if 'rowNumber' in options and options['rowNumber'] is not None:
|
2015-09-06 20:28:20 +00:00
|
|
|
options['rowNumber'] += 1
|
|
|
|
else:
|
|
|
|
options['rowNumber'] = 1
|
|
|
|
|
|
|
|
if 'counterColName' not in options:
|
|
|
|
options['counterColName'] = 'counter'
|
|
|
|
|
|
|
|
if 'targetColName' not in options:
|
|
|
|
options['targetColName'] = 'target'
|
2015-09-07 05:49:04 +00:00
|
|
|
options['targetRowNumber'] = options['rowNumber']
|
2015-09-06 20:28:20 +00:00
|
|
|
|
2017-10-04 00:06:53 +00:00
|
|
|
print("After: ", options)
|
2015-09-06 20:28:20 +00:00
|
|
|
vis.options = json.dumps(options)
|
|
|
|
vis.save()
|