mostVisitedKeys method

  1. @override
Future<Map<String, int>> mostVisitedKeys(
  1. int length
)
override

Top length lookup keys by access-log entry count. Result map: lookup-key → visit count, ordered by descending count.

Implementation

@override
Future<Map<String, int>> mostVisitedKeys(int length) async {
  final rows = _db.raw.select(
      "SELECT lookup_key k, COUNT(*) c FROM access_log WHERE verb_name = 'lookup' "
      'AND lookup_key IS NOT NULL GROUP BY lookup_key ORDER BY c DESC LIMIT ?;',
      [length]);
  return {for (final r in rows) r['k'] as String: r['c'] as int};
}