[chronojump/chronojump-importer] Fixes update_persons_77_ids: it was doing nothing. Fixes unit tests.
- From: Carles Pina i Estany <carlespina src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/chronojump-importer] Fixes update_persons_77_ids: it was doing nothing. Fixes unit tests.
- Date: Wed, 7 Sep 2016 12:33:36 +0000 (UTC)
commit bf4fb167f08e3e855c966f36ae3eb67705fa3c0a
Author: Carles Pina i Estany <carles pina cat>
Date: Wed Sep 7 13:33:08 2016 +0100
Fixes update_persons_77_ids: it was doing nothing. Fixes unit tests.
src/chronojump-importer/chronojump_importer.py | 34 ++++++++++----------
.../tests/generic-expected-b.sqlite | Bin 61440 -> 61440 bytes
.../tests/generic-expected-c.sqlite | Bin 61440 -> 61440 bytes
3 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/src/chronojump-importer/chronojump_importer.py b/src/chronojump-importer/chronojump_importer.py
index eeb504e..efb0072 100755
--- a/src/chronojump-importer/chronojump_importer.py
+++ b/src/chronojump-importer/chronojump_importer.py
@@ -190,22 +190,6 @@ def insert_dictionary_into_table(cursor, table_name, row, skip_columns=["uniqueI
return new_id
-def update_persons77_ids(table, persons77_list):
- """ table argument is a list of dictionaries. It returns a copy of it
- replacing each personID by the 'new' personID contained in persons77_list.
- persons77_list is a list of dictionaries and they must contain uniqueID (old person ID) and
- new_unique_id -the new one in the new database. """
- result = copy.deepcopy(table)
-
- for row in table:
- old_person_id = row['personID']
- for persons77 in persons77_list:
- if persons77['uniqueID'] == old_person_id:
- row['personID'] = persons77['new_unique_id']
-
- return result
-
-
def update_session_ids(table, new_session_id):
""" table argument is a list of dictionaries. It returns a copy of it
replacing each sessionID by new_session_id.
@@ -240,6 +224,7 @@ def print_summary(table_name, table_data):
print("\tinserted: {inserted_counter} uniqueIDs: {inserted}".format(inserted_counter=len(inserted_ids),
inserted=inserted_ids))
print("\treused: {reused_counter} uniqueIDs: {reused}".format(reused_counter=len(reused_ids),
reused=reused_ids))
+
def remove_duplicates_list(l):
""" Returns a new list without duplicate elements. """
result = []
@@ -286,6 +271,22 @@ def avoids_column_duplicate(cursor, table_name, column_name, data_row):
data_row['new_' + column_name] = data_row[column_name]
+def update_persons77_ids(table, persons77_list):
+ """ table argument is a list of dictionaries. It returns a copy of it
+ replacing each personID by the 'new' personID contained in persons77_list.
+ persons77_list is a list of dictionaries and they must contain uniqueID (old person ID) and
+ new_unique_id -the new one in the new database. """
+ result = copy.deepcopy(table)
+
+ for row in result:
+ old_person_id = row['personID']
+ for persons77 in persons77_list:
+ if persons77['uniqueID'] == old_person_id:
+ row['personID'] = persons77['new_unique_id']
+
+ return result
+
+
def update_jump_types(table, jump_types):
""" TODO: refactor with update_persons77_ids"""
result = copy.deepcopy(table)
@@ -375,7 +376,6 @@ def import_database(source_path, destination_path, source_session):
jump_rj = update_session_ids(jump_rj, new_session_id)
jump_rj = update_jump_types(jump_rj, jump_rj_types)
-
insert_data_into_table(cursor=destination_cursor, table_name="JumpRj", data=jump_rj,
matches_columns=None)
# Imports Jump table (with the new Person77's uniqueIDs)
diff --git a/src/chronojump-importer/tests/generic-expected-b.sqlite
b/src/chronojump-importer/tests/generic-expected-b.sqlite
index d14d148..81b9a51 100644
Binary files a/src/chronojump-importer/tests/generic-expected-b.sqlite and
b/src/chronojump-importer/tests/generic-expected-b.sqlite differ
diff --git a/src/chronojump-importer/tests/generic-expected-c.sqlite
b/src/chronojump-importer/tests/generic-expected-c.sqlite
index 0708c99..4c06ff0 100644
Binary files a/src/chronojump-importer/tests/generic-expected-c.sqlite and
b/src/chronojump-importer/tests/generic-expected-c.sqlite differ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]