upload method
Implementation
Future<List<DataValueSet>?> upload(Function(RequestProgress, bool) callback,
{Dio? dioTestClient}) async {
List<DataValueSet> dataValueSets = await this
.where(attribute: 'synced', value: false)
.where(attribute: 'dirty', value: true)
.withDataValues()
.get();
List<String> dataValueSetIds = [];
final queue = Queue(parallel: 50);
num availableItemCount = 0;
dataValueSets.forEach((dataValueSet) {
dataValueSetIds.add(dataValueSet.id as String);
availableItemCount++;
queue.add(
() => this.uploadOne(dataValueSet, dioTestClient: dioTestClient));
});
if (availableItemCount == 0) {
queue.cancel();
} else {
await queue.onComplete;
}
return await DataValueSetQuery(database: database)
.byIds(dataValueSetIds)
.get();
}