Merge remote-tracking branch 'origin/bug/channel_lost_data' into dev/merge_channel_lost_data
This commit is contained in:
@@ -361,24 +361,14 @@ class DataBaseProcess(Process):
|
||||
return None
|
||||
|
||||
def data_raw_recording(self, _id_dict, _channel_list, _data_dict):
|
||||
for _channel in _channel_list:
|
||||
compressed_value = _data_dict[_channel] + '"***"'
|
||||
# compressed_value = bytes(_data_dict[_channel],'utf-8')
|
||||
# compressed_value = zlib.compress(compressed_value)
|
||||
# compressed_value = base64.b64encode(compressed_value).decode() + '"***"'
|
||||
# compressed_value = _data + '"***"'
|
||||
sql_str = 'UPDATE "public"."' + str(_channel) + '_recording_data_raws" SET data = concat(data, %s) where id = %s'
|
||||
sql_set = [compressed_value, _id_dict[_channel]]
|
||||
with self._psql_conn as conn:
|
||||
with conn.cursor() as sql_cursor:
|
||||
for _channel in _channel_list:
|
||||
sql_str = 'UPDATE "public"."' + str(_channel) + '_recording_data_raws" SET data = concat(data, %s) where id = %s'
|
||||
sql_set = [_data_dict[_channel] + '"***"', _id_dict[_channel]]
|
||||
sql_cursor.execute(sql_str, sql_set)
|
||||
|
||||
|
||||
sql_cursor = self._psql_conn.cursor()
|
||||
sql_cursor.execute(sql_str, sql_set)
|
||||
self._psql_conn.commit()
|
||||
sql_cursor.close()
|
||||
|
||||
del _data_dict[_channel]
|
||||
del compressed_value
|
||||
gc.collect()
|
||||
# _conn.close()
|
||||
return None
|
||||
|
||||
def data_mini_create(self, _data_dict, _channel_list, _scale, device_id):
|
||||
@@ -415,38 +405,24 @@ class DataBaseProcess(Process):
|
||||
return True
|
||||
|
||||
def data_mini_recording(self, _id_dict, _channel_list, _start_time_dict, _data_mean_dict):
|
||||
for _channel in _channel_list:
|
||||
data = _data_mean_dict.get(_channel)
|
||||
if data is not None:
|
||||
if len(data) != 0:
|
||||
str_mean = [str(int) for int in _data_mean_dict[_channel]]
|
||||
data_mean = _start_time_dict[_channel] + ' ' + ' '.join(str_mean)
|
||||
# data_random = _start_time_dict[_channel] + ' ' + ' '.join(_data_random_dict[_channel])
|
||||
# data_bar = _start_time_dict[_channel] + ' ' + ' '.join(_data_bar_dict[_channel])
|
||||
with self._psql_conn as conn:
|
||||
with self._psql_conn.cursor() as sql_cursor:
|
||||
for _channel in _channel_list:
|
||||
data = _data_mean_dict.get(_channel)
|
||||
if data is not None:
|
||||
if len(data) != 0:
|
||||
str_mean = [str(int) for int in _data_mean_dict[_channel]]
|
||||
data_mean = _start_time_dict[_channel] + ' ' + ' '.join(str_mean)
|
||||
|
||||
compressed_mean = data_mean + '"***"'
|
||||
|
||||
# compressed_mean = bytes(data_mean,'utf-8')
|
||||
# compressed_mean = zlib.compress(compressed_mean)
|
||||
# compressed_mean = base64.b64encode(compressed_mean).decode() + '"***"'
|
||||
|
||||
# compressed_random = bytes(data_bar,'utf-8')
|
||||
# compressed_random = zlib.compress(compressed_random)
|
||||
# compressed_random = base64.b64encode(compressed_random).decode() + '"***"'
|
||||
|
||||
# compressed_random = bytes(data_random,'utf-8')
|
||||
# compressed_random = zlib.compress(compressed_random)
|
||||
# compressed_random = base64.b64encode(compressed_random).decode() + '"***"'
|
||||
sql_str = 'UPDATE "public"."' + str(_channel) + '_recording_data_minis" SET data_mean = concat(data_mean, %s) where id = %s'
|
||||
sql_set = [compressed_mean, _id_dict[_channel]]
|
||||
|
||||
sql_cursor = self._psql_conn.cursor()
|
||||
sql_set = [data_mean + '"***"', _id_dict[_channel]]
|
||||
sql_cursor.execute(sql_str, sql_set)
|
||||
self._psql_conn.commit()
|
||||
sql_cursor.close()
|
||||
|
||||
del str_mean, _start_time_dict[_channel], _data_mean_dict[_channel], data_mean, compressed_mean
|
||||
gc.collect()
|
||||
del str_mean, data_mean
|
||||
|
||||
for _channel in _channel_list:
|
||||
del _start_time_dict[_channel], _data_mean_dict[_channel]
|
||||
gc.collect()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user