-
Notifications
You must be signed in to change notification settings - Fork 43
#302 #388
base: master
Are you sure you want to change the base?
#302 #388
Conversation
Bray rounds have changed to 10 ends of 3 arrows each
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your PR!
I really appreciate the work you have put into this :)
val db = testHelper.createDatabase(TEST_DB_NAME, 26) | ||
insertTrainingDataForVersion26(db) | ||
|
||
val count = db.query("select * from StandardRound").count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor stylistic issue, but could you please uppercase the SQL keywords select
->SELECT
from
->FROM
to be consistent with the rest of the app and to make them easier distinguishable from table and column names?
) | ||
|
||
|
||
database.query("SELECT `id`, `targetId`, `targetScoringStyleIndex`, `targetDiameter` FROM `Round` WHERE trainingId IN (SELECT t.id FROM Training as t JOIN StandardRound as s WHERE s.name in ('Bray I', 'Bray II'))") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to break this query up into multiple lines so that it's easier to read.
) | ||
database.execSQL( | ||
"UPDATE Round SET shotsPerEnd=3, maxEndCount=10 " + | ||
"WHERE trainingId IN (SELECT t.id FROM Training as t JOIN StandardRound as s WHERE s.name ='Bray I')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately you cannot use the name here (and in the queries below) to filter for the correct round the the name is language dependent and might be different for other locales. It is save to assume that the round always has the same ID as it is always inserted into the database as first in a specified order.
|
||
fun addEnd(database: SupportSQLiteDatabase, target: Target, end: End, fileName: String?, index: Int) { | ||
val shots = mutableListOf<Shot>() | ||
database.query("SELECT `id`, `index`, `scoringRing` FROM Shot WHERE endId = ${end.id} LIMIT 3") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit dangerous as the result of LIMIT is not deterministic if no SORT BY
clause is given. (Should be sorted by id)
val cursor = database.query("SELECT `fileName` FROM `EndImage` WHERE `endId` = ${end.id}") | ||
var fileName: String? = null | ||
if (cursor.moveToFirst()) { | ||
fileName = cursor.getString(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An end can have multiple images not just zero or one. The rest would be lost.
} | ||
|
||
private fun deleteEnds(database: SupportSQLiteDatabase, ids: String) { | ||
database.execSQL("delete from end where id in (" + ids + ")") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also use uppercase commands here and camelcase for the table names
multiple EndImages for an End
Bray rounds have changed to 10 ends of 3 arrows each