Enhance cleanup dialog with sensitivity slider for problematic entries
This commit is contained in:
@@ -162,14 +162,14 @@ Future<List<Note>> searchNotes(String query) async {
|
||||
}
|
||||
|
||||
// Find potentially problematic entries based on character distribution
|
||||
Future<List<Note>> findProblematicEntries() async {
|
||||
const double maxCharPercentage = 0.7; // If a single char makes up more than 70%, it's suspicious
|
||||
const int minLength = 10; // Only check notes longer than this
|
||||
|
||||
Future<List<Note>> findProblematicEntries({
|
||||
double maxCharPercentage = 0.7,
|
||||
}) async {
|
||||
// Simple SQLite query that counts character occurrences using replace
|
||||
final List<Map<String, dynamic>> results = await DB.db.rawQuery('''
|
||||
final List<Map<String, dynamic>> results = await DB.db.rawQuery(
|
||||
'''
|
||||
WITH char_counts AS (
|
||||
SELECT
|
||||
SELECT
|
||||
id,
|
||||
date,
|
||||
content,
|
||||
@@ -178,18 +178,24 @@ Future<List<Note>> findProblematicEntries() async {
|
||||
length(content) as total_length,
|
||||
cast(length(content) - length(replace(content, substr(content, 1, 1), '')) as float) / length(content) as percentage
|
||||
FROM notes
|
||||
WHERE length(content) >= ?
|
||||
)
|
||||
SELECT *
|
||||
FROM char_counts
|
||||
WHERE percentage > ?
|
||||
ORDER BY date DESC
|
||||
''', [minLength, maxCharPercentage]);
|
||||
''',
|
||||
[maxCharPercentage],
|
||||
);
|
||||
|
||||
return results.map((row) => Note(
|
||||
date: row['date'] as String,
|
||||
content: row['content'] as String,
|
||||
isProblematic: true,
|
||||
problemReason: 'Character "${row['char']}" makes up ${(row['percentage'] * 100).toStringAsFixed(1)}% of the content',
|
||||
)).toList();
|
||||
return results
|
||||
.map(
|
||||
(row) => Note(
|
||||
date: row['date'] as String,
|
||||
content: row['content'] as String,
|
||||
isProblematic: true,
|
||||
problemReason:
|
||||
'Character "${row['char']}" makes up ${(row['percentage'] * 100).toStringAsFixed(1)}% of the content',
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
|
Reference in New Issue
Block a user