getUserTasks method
Get the list of UserTaskSnapshot for study.
If study is null, all user tasks are returned.
Implementation
Future<List<UserTaskSnapshot>> getUserTasks([SmartphoneStudy? study]) async {
List<UserTaskSnapshot> result = [];
try {
final List<Map<String, Object?>> list =
await _database?.query(
TASK_QUEUE_TABLE_NAME,
columns: [TASK_COLUMN],
where: study != null
? '$STUDY_DEPLOYMENT_ID_COLUMN = ? AND $DEVICE_ROLE_NAME_COLUMN = ?'
: null,
whereArgs: study != null
? [study.studyDeploymentId, study.deviceRoleName]
: null,
) ??
[];
if (list.isNotEmpty) {
for (var element in list) {
final jsonString = element[TASK_COLUMN] as String;
result.add(
UserTaskSnapshot.fromJson(
json.decode(jsonString) as Map<String, dynamic>,
),
);
}
}
} catch (exception) {
warning('$runtimeType - Failed to load task queue - $exception');
}
return result;
}