DatabaseHelper: add getTreatmentByDate.
This commit is contained in:
parent
74bbab9cf1
commit
744d24cbcf
1 changed files with 18 additions and 0 deletions
|
@ -680,6 +680,24 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Treatment getTreatmentByDate(long mills) {
|
||||||
|
try {
|
||||||
|
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
|
||||||
|
List<Treatment> treatments;
|
||||||
|
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
|
||||||
|
Where where = queryBuilder.where();
|
||||||
|
where.eq("date", mills);
|
||||||
|
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
||||||
|
treatments = daoTreatments.query(preparedQuery);
|
||||||
|
// date is unique
|
||||||
|
return treatments.isEmpty() ? null : treatments.get(0);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<Treatment> getTreatmentDataFromTime(long mills, boolean ascending) {
|
public List<Treatment> getTreatmentDataFromTime(long mills, boolean ascending) {
|
||||||
try {
|
try {
|
||||||
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
|
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
|
||||||
|
|
Loading…
Reference in a new issue