41 lines
1.1 KiB
Dart
41 lines
1.1 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:jadb/table_names/tanos_jlpt.dart';
|
|
import 'package:sqflite_common/sqlite_api.dart';
|
|
|
|
Future<void> seedTanosJLPTData(
|
|
Map<String, Set<int>> resolvedEntries,
|
|
Database db,
|
|
) async {
|
|
final Batch b = db.batch();
|
|
|
|
if (Platform.environment['TANOS_JLPT_VERSION'] != null &&
|
|
Platform.environment['TANOS_JLPT_DATE'] != null &&
|
|
Platform.environment['TANOS_JLPT_HASH'] != null) {
|
|
b.insert(TanosJLPTTableNames.version, {
|
|
'version': Platform.environment['TANOS_JLPT_VERSION']!,
|
|
'date': Platform.environment['TANOS_JLPT_DATE']!,
|
|
'hash': Platform.environment['TANOS_JLPT_HASH']!,
|
|
});
|
|
} else {
|
|
print(
|
|
'WARNING: Tanos JLPT version information not found in environment variables. '
|
|
'This may cause issues with future updates.',
|
|
);
|
|
}
|
|
|
|
for (final jlptLevel in resolvedEntries.entries) {
|
|
final level = jlptLevel.key;
|
|
final entryIds = jlptLevel.value;
|
|
|
|
for (final entryId in entryIds) {
|
|
b.insert(TanosJLPTTableNames.jlptTag, {
|
|
'entryId': entryId,
|
|
'jlptLevel': level,
|
|
});
|
|
}
|
|
}
|
|
|
|
await b.commit(noResult: true);
|
|
}
|