|
@@ -1267,7 +1267,7 @@ processCsvData(File tempfile, SupabaseClient supabase) async {
|
|
|
final scopeInNew = mapsToInsert
|
|
final scopeInNew = mapsToInsert
|
|
|
.fold(<String>{}, (t, e) => t..add(e[scopeName] ?? "")).toList();
|
|
.fold(<String>{}, (t, e) => t..add(e[scopeName] ?? "")).toList();
|
|
|
|
|
|
|
|
- print("Loading old data scope: ${scopeInNew.length}");
|
|
|
|
|
|
|
+ // print("Loading old data scope: ${scopeInNew.length}");
|
|
|
List<Map<String, dynamic>> old = [];
|
|
List<Map<String, dynamic>> old = [];
|
|
|
for (var e in splitList(scopeInNew, headerToNb(scopeInNew))) {
|
|
for (var e in splitList(scopeInNew, headerToNb(scopeInNew))) {
|
|
|
final res = await supabase
|
|
final res = await supabase
|
|
@@ -1276,7 +1276,7 @@ processCsvData(File tempfile, SupabaseClient supabase) async {
|
|
|
.inFilter(scopeName, e)
|
|
.inFilter(scopeName, e)
|
|
|
.limit(100000);
|
|
.limit(100000);
|
|
|
old.addAll(res);
|
|
old.addAll(res);
|
|
|
- print("Loaded old data scope: ${e.length}");
|
|
|
|
|
|
|
+ // print("Loaded old data scope: ${e.length}");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Replace with your actual table name
|
|
// Replace with your actual table name
|
|
@@ -1286,7 +1286,7 @@ processCsvData(File tempfile, SupabaseClient supabase) async {
|
|
|
|
|
|
|
|
List<int> indexToRemove = [];
|
|
List<int> indexToRemove = [];
|
|
|
List<int> indexToMaintain = [];
|
|
List<int> indexToMaintain = [];
|
|
|
- print("Deleting old data scope: ${mapsToInsert.length}");
|
|
|
|
|
|
|
+ // print("Deleting old data scope: ${mapsToInsert.length}");
|
|
|
for (int i = 0; i < oldComparable.length; i++) {
|
|
for (int i = 0; i < oldComparable.length; i++) {
|
|
|
final item = oldComparable[i];
|
|
final item = oldComparable[i];
|
|
|
final index = findIndex(mapsToInsert, item);
|
|
final index = findIndex(mapsToInsert, item);
|
|
@@ -1298,11 +1298,11 @@ processCsvData(File tempfile, SupabaseClient supabase) async {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- print(
|
|
|
|
|
- " indexToRemove: ${indexToRemove.length} , indexToMaintain: ${indexToMaintain.length}");
|
|
|
|
|
- print("delete from db");
|
|
|
|
|
|
|
+ // print(
|
|
|
|
|
+ // " indexToRemove: ${indexToRemove.length} , indexToMaintain: ${indexToMaintain.length}");
|
|
|
|
|
+ // print("delete from db");
|
|
|
|
|
|
|
|
- print("delete from db ${indexToRemove.length}");
|
|
|
|
|
|
|
+ // print("delete from db ${indexToRemove.length}");
|
|
|
|
|
|
|
|
for (var e in splitList(indexToRemove.map((e) => old[e]['id']).toList(),
|
|
for (var e in splitList(indexToRemove.map((e) => old[e]['id']).toList(),
|
|
|
headerToNb(indexToRemove.map((e) => old[e]['id']).toList()))) {
|
|
headerToNb(indexToRemove.map((e) => old[e]['id']).toList()))) {
|
|
@@ -1310,7 +1310,7 @@ processCsvData(File tempfile, SupabaseClient supabase) async {
|
|
|
.from(tables[data.filename]!) // Replace with your actual table name
|
|
.from(tables[data.filename]!) // Replace with your actual table name
|
|
|
.delete()
|
|
.delete()
|
|
|
.inFilter('id', e);
|
|
.inFilter('id', e);
|
|
|
- print("Deleted old data scope: ${e.length}");
|
|
|
|
|
|
|
+ // print("Deleted old data scope: ${e.length}");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// splitList(indexToRemove.map((e) => old[e]['id']).toList(), 200).forEach(
|
|
// splitList(indexToRemove.map((e) => old[e]['id']).toList(), 200).forEach(
|
|
@@ -1319,7 +1319,7 @@ processCsvData(File tempfile, SupabaseClient supabase) async {
|
|
|
// tables[data.filename]!) // Replace with your actual table name
|
|
// tables[data.filename]!) // Replace with your actual table name
|
|
|
// .delete()
|
|
// .delete()
|
|
|
// .inFilter('id', e));
|
|
// .inFilter('id', e));
|
|
|
- print("insert in db");
|
|
|
|
|
|
|
+ // print("insert in db");
|
|
|
|
|
|
|
|
await supabase
|
|
await supabase
|
|
|
.from(tables[data.filename]!) // Replace with your actual table name
|
|
.from(tables[data.filename]!) // Replace with your actual table name
|
|
@@ -1334,7 +1334,7 @@ processCsvData(File tempfile, SupabaseClient supabase) async {
|
|
|
// splitList(mapsToInsert, 200).forEach((e) async => await supabase
|
|
// splitList(mapsToInsert, 200).forEach((e) async => await supabase
|
|
|
// .from(tables[data.filename]!) // Replace with your actual table name
|
|
// .from(tables[data.filename]!) // Replace with your actual table name
|
|
|
// .insert(e));
|
|
// .insert(e));
|
|
|
- print("end");
|
|
|
|
|
|
|
+ // print("end");
|
|
|
|
|
|
|
|
// print(createListOfMaps(headers[data.filename] ?? [], csv2list(data.data)));
|
|
// print(createListOfMaps(headers[data.filename] ?? [], csv2list(data.data)));
|
|
|
} else {
|
|
} else {
|
|
@@ -1400,6 +1400,6 @@ int headerToNb(List list) {
|
|
|
final length1 = (list.toString().length / list.length).ceil() * 8;
|
|
final length1 = (list.toString().length / list.length).ceil() * 8;
|
|
|
final lengthurl = 200 * 8;
|
|
final lengthurl = 200 * 8;
|
|
|
final res = ((maxheader - lengthurl) / length1).floor();
|
|
final res = ((maxheader - lengthurl) / length1).floor();
|
|
|
- print("header2nb: $res");
|
|
|
|
|
|
|
+ //print("header2nb: $res");
|
|
|
return res;
|
|
return res;
|
|
|
}
|
|
}
|