treewide: dart format
This commit is contained in:
@@ -36,14 +36,17 @@ class CreateDb extends Command {
|
||||
);
|
||||
|
||||
bool failed = false;
|
||||
await seedData(db).then((_) {
|
||||
print("Database created successfully");
|
||||
}).catchError((error) {
|
||||
print("Error creating database: $error");
|
||||
failed = true;
|
||||
}).whenComplete(() {
|
||||
db.close();
|
||||
});
|
||||
await seedData(db)
|
||||
.then((_) {
|
||||
print("Database created successfully");
|
||||
})
|
||||
.catchError((error) {
|
||||
print("Error creating database: $error");
|
||||
failed = true;
|
||||
})
|
||||
.whenComplete(() {
|
||||
db.close();
|
||||
});
|
||||
if (failed) {
|
||||
exit(1);
|
||||
} else {
|
||||
|
||||
@@ -63,7 +63,8 @@ Future<void> resolveExisting(
|
||||
for (final (i, word) in rankedWords.indexed) {
|
||||
try {
|
||||
print(
|
||||
'[${(i + 1).toString().padLeft(4, '0')}/${rankedWords.length}] ${word.toString()}');
|
||||
'[${(i + 1).toString().padLeft(4, '0')}/${rankedWords.length}] ${word.toString()}',
|
||||
);
|
||||
await findEntry(word, db, useOverrides: useOverrides);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
@@ -78,16 +79,19 @@ Future<void> resolveExisting(
|
||||
|
||||
print('Statistics:');
|
||||
for (final jlptLevel in ['N5', 'N4', 'N3', 'N2', 'N1']) {
|
||||
final missingWordCount =
|
||||
missingWords.where((e) => e.jlptLevel == jlptLevel).length;
|
||||
final totalWordCount =
|
||||
rankedWords.where((e) => e.jlptLevel == jlptLevel).length;
|
||||
final missingWordCount = missingWords
|
||||
.where((e) => e.jlptLevel == jlptLevel)
|
||||
.length;
|
||||
final totalWordCount = rankedWords
|
||||
.where((e) => e.jlptLevel == jlptLevel)
|
||||
.length;
|
||||
|
||||
final failureRate =
|
||||
((missingWordCount / totalWordCount) * 100).toStringAsFixed(2);
|
||||
final failureRate = ((missingWordCount / totalWordCount) * 100)
|
||||
.toStringAsFixed(2);
|
||||
|
||||
print(
|
||||
'${jlptLevel} failures: [${missingWordCount}/${totalWordCount}] (${failureRate}%)');
|
||||
'${jlptLevel} failures: [${missingWordCount}/${totalWordCount}] (${failureRate}%)',
|
||||
);
|
||||
}
|
||||
|
||||
print('Not able to determine the entry for ${missingWords.length} words');
|
||||
|
||||
@@ -17,24 +17,11 @@ class QueryWord extends Command {
|
||||
addLibsqliteArg(argParser);
|
||||
addJadbArg(argParser);
|
||||
|
||||
argParser.addFlag(
|
||||
'json',
|
||||
abbr: 'j',
|
||||
help: 'Output results in JSON format',
|
||||
);
|
||||
argParser.addFlag('json', abbr: 'j', help: 'Output results in JSON format');
|
||||
|
||||
argParser.addOption(
|
||||
'page',
|
||||
abbr: 'p',
|
||||
valueHelp: 'NUM',
|
||||
defaultsTo: '1',
|
||||
);
|
||||
argParser.addOption('page', abbr: 'p', valueHelp: 'NUM', defaultsTo: '1');
|
||||
|
||||
argParser.addOption(
|
||||
'pageSize',
|
||||
valueHelp: 'NUM',
|
||||
defaultsTo: '30',
|
||||
);
|
||||
argParser.addOption('pageSize', valueHelp: 'NUM', defaultsTo: '30');
|
||||
}
|
||||
|
||||
Future<void> run() async {
|
||||
@@ -62,11 +49,7 @@ class QueryWord extends Command {
|
||||
final int? maybeId = int.tryParse(searchWord);
|
||||
|
||||
if (maybeId != null && maybeId >= 1000000) {
|
||||
await _searchId(
|
||||
db,
|
||||
maybeId,
|
||||
argResults!.flag('json'),
|
||||
);
|
||||
await _searchId(db, maybeId, argResults!.flag('json'));
|
||||
} else {
|
||||
await _searchWord(
|
||||
db,
|
||||
@@ -78,11 +61,7 @@ class QueryWord extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _searchId(
|
||||
DatabaseExecutor db,
|
||||
int id,
|
||||
bool jsonOutput,
|
||||
) async {
|
||||
Future<void> _searchId(DatabaseExecutor db, int id, bool jsonOutput) async {
|
||||
final time = Stopwatch()..start();
|
||||
final result = await JaDBConnection(db).jadbGetWordById(id);
|
||||
time.stop();
|
||||
@@ -112,11 +91,9 @@ class QueryWord extends Command {
|
||||
time.stop();
|
||||
|
||||
final time2 = Stopwatch()..start();
|
||||
final result = await JaDBConnection(db).jadbSearchWord(
|
||||
searchWord,
|
||||
page: page,
|
||||
pageSize: pageSize,
|
||||
);
|
||||
final result = await JaDBConnection(
|
||||
db,
|
||||
).jadbSearchWord(searchWord, page: page, pageSize: pageSize);
|
||||
time2.stop();
|
||||
|
||||
if (result == null) {
|
||||
|
||||
Reference in New Issue
Block a user