Group addresses for access notifications

This commit is contained in:
M66B 2016-02-07 09:43:28 +01:00
parent a2c1f1c5eb
commit 11dadcf93f
1 changed files with 7 additions and 3 deletions

View File

@ -454,9 +454,13 @@ public class DatabaseHelper extends SQLiteOpenHelper {
public Cursor getAccessUnset(int uid) {
SQLiteDatabase db = this.getReadableDatabase();
return db.query("access", null,
"uid = ? AND block < 0", new String[]{Integer.toString(uid)},
null, null, "time DESC");
String query = "SELECT MAX(time) AS time, daddr, allowed";
query += " FROM access";
query += " WHERE uid = ?";
query += " AND block < 0";
query += " GROUP BY daddr, allowed";
query += " ORDER BY time DESC";
return db.rawQuery(query, new String[]{Integer.toString(uid)});
}
public long getRuleCount(int uid) {