Commit 8a64137e authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Made responseSource non-null, use UPSTREAM as default

parent 975e8394
......@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 11,
"identityHash": "fb5d5231e14e3e9fbd2d47ee90178b0f",
"identityHash": "6593a50157ce88fb018043b5c151353a",
"entities": [
{
"tableName": "CachedResponse",
......@@ -39,7 +39,7 @@
},
{
"tableName": "DnsQuery",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `name` TEXT NOT NULL, `askedServer` TEXT, `responseSource` TEXT, `questionTime` INTEGER NOT NULL, `responseTime` INTEGER NOT NULL, `responses` TEXT NOT NULL)",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `name` TEXT NOT NULL, `askedServer` TEXT, `responseSource` TEXT NOT NULL, `questionTime` INTEGER NOT NULL, `responseTime` INTEGER NOT NULL, `responses` TEXT NOT NULL)",
"fields": [
{
"fieldPath": "id",
......@@ -69,7 +69,7 @@
"fieldPath": "responseSource",
"columnName": "responseSource",
"affinity": "TEXT",
"notNull": false
"notNull": true
},
{
"fieldPath": "questionTime",
......@@ -252,7 +252,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'fb5d5231e14e3e9fbd2d47ee90178b0f')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '6593a50157ce88fb018043b5c151353a')"
]
}
}
\ No newline at end of file
......@@ -59,8 +59,7 @@ class QueryImportActivity: AppCompatActivity() {
val source = if(split[5].equals("false", true) || split[5].equals("true", true)) {
if (split[5].toBoolean()) QueryListener.Source.CACHE
else QueryListener.Source.UPSTREAM
} else if(split[5].isBlank()) null
else QueryListener.Source.values().find {
} else QueryListener.Source.values().find {
it.name.equals(split[5], true)
}
queries.add(DnsQuery(
......
......@@ -99,7 +99,7 @@ val MIGRATION_9_10 = migration(9, 10) {
val MIGRATION_10_11 = migration(10, 11) {
Logger.logIfOpen("DB_MIGRATION", "Migrating from 10 to 11")
it.execSQL("CREATE TABLE `DnsQuery_tmp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `name` TEXT NOT NULL, `askedServer` TEXT, `responseSource` TEXT, `questionTime` INTEGER NOT NULL, `responseTime` INTEGER NOT NULL, `responses` TEXT NOT NULL)")
it.execSQL("CREATE TABLE `DnsQuery_tmp` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `type` INTEGER NOT NULL, `name` TEXT NOT NULL, `askedServer` TEXT, `responseSource` TEXT NOT NULL, `questionTime` INTEGER NOT NULL, `responseTime` INTEGER NOT NULL, `responses` TEXT NOT NULL)")
it.execSQL("INSERT INTO `DnsQuery_tmp`(id, type, name, askedServer, questionTime, responseTime, responses, responseSource) SELECT id, type, name, askedServer, questionTime, responseTime, responses, CASE WHEN fromCache=1 THEN 'CACHE' else 'UPSTREAM' END as `responseSource` FROM DnsQuery")
it.execSQL("DROP TABLE `DnsQuery`")
it.execSQL("ALTER TABLE `DnsQuery_tmp` RENAME TO `DnsQuery`")
......
......@@ -37,7 +37,7 @@ data class DnsQuery(
val type: Record.TYPE,
val name: String,
var askedServer: String?,
var responseSource:QueryListener.Source? = null,
var responseSource:QueryListener.Source,
val questionTime: Long,
var responseTime: Long = 0,
var responses: MutableList<String>
......
......@@ -53,7 +53,6 @@ class QueryListener(private val context: Context) : QueryListener {
if (logQueriesToDb) {
val query = waitingQueryLogs[questionMessage.id] ?: return
query.askedServer = askedServer
query.responseSource = QueryListener.Source.UPSTREAM
context.getDatabase().dnsQueryDao().update(query)
}
}
......@@ -67,6 +66,7 @@ class QueryListener(private val context: Context) : QueryListener {
type = questionMessage.question.type,
name = questionMessage.question.name.toString(),
askedServer = null,
responseSource = QueryListener.Source.UPSTREAM,
questionTime = System.currentTimeMillis(),
responses = mutableListOf()
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment