[chronojump/FS-TFT-Menu] Fixed Chronojump importer issue: https://gitlab.gnome.org/GNOME/chronojump/-/issues/691
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/FS-TFT-Menu] Fixed Chronojump importer issue: https://gitlab.gnome.org/GNOME/chronojump/-/issues/691
- Date: Wed, 20 Apr 2022 11:59:23 +0000 (UTC)
commit f0ca27a3932f845708e2b4966b79071ea5e08dec
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Apr 7 11:36:21 2022 +0200
Fixed Chronojump importer issue: https://gitlab.gnome.org/GNOME/chronojump/-/issues/691
src/chronojump-importer/chronojump_importer.py | 30 ++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
---
diff --git a/src/chronojump-importer/chronojump_importer.py b/src/chronojump-importer/chronojump_importer.py
index 99e4d9b4c..e7e58e69c 100755
--- a/src/chronojump-importer/chronojump_importer.py
+++ b/src/chronojump-importer/chronojump_importer.py
@@ -267,6 +267,36 @@ class Database:
results = self._cursor.fetchall()
+ """ If we don't find results on a name (typical avoids_duplicate_column field),
+ then try also on name + " (%)" with like statement,
+ maybe we can check also if % matched content is a number.
+ Better description here:
+ https://gitlab.gnome.org/GNOME/chronojump/-/issues/691
+ Following code fixes it
+ """
+ if avoids_duplicate_column is not None and len(results) == 0:
+ where = ""
+ where_values = []
+ for column in matches_columns:
+ if where != "":
+ where += " AND "
+ if column == avoids_duplicate_column:
+ where += "{} like ?".format(column)
+ where_values.append(row.get(column) + " (%)")
+ else:
+ where += "{} = ?".format(column)
+ where_values.append(row.get(column))
+
+ format_data = {'table_name': table.name,
+ 'where_clause': " WHERE {}".format(where)
+ }
+
+ sql = "SELECT uniqueID FROM {table_name} {where_clause}".format(**format_data)
+ self._execute_query_and_log(sql, where_values)
+
+ results = self._cursor.fetchall()
+ # TODO: need to delete the results: name + (notanumber)
+
if matches_columns is None or len(results) == 0:
# Needs to insert it
self._avoid_duplicate_value(table_name=table.name, column_name=avoids_duplicate_column,
data_row=row)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]