protected async Task <bool> DoRegularLoadAsync(bool fullLoad) { int loadCount = IncrementalLoadMax - ReserveSize; ITableQueryAsync <Card> tableQuery = Db.Table <Card>() .Where( c => c.PracticeState == PracticeState.New && !Objects.Select(o => o.Id).Contains(c.Id)) .Take(loadCount); if (!fullLoad) { tableQuery = tableQuery.ShallowLoad(LazyLoader); } tableQuery = Random ? tableQuery.OrderByRand() : tableQuery.OrderBy(c => c.Due); int loadedCount = await AddItemsAsync(tableQuery).ConfigureAwait(false); if (loadedCount < loadCount) { Status = ReviewStatus.MoveNextEndOfStore; } else if (fullLoad) { FurtherLoadedIndex = loadedCount - 1; } return(loadedCount > 0); }
protected async Task <bool> DoRegularLoadAsync(bool fullLoad) { int loadCount = IncrementalLoadMax - ReserveSize; int tomorrow = DateTimeExtensions.Tomorrow.ToUnixTimestamp(); // Prepare query ITableQueryAsync <Card> tableQuery = Db.Table <Card>() .Where( c => c.PracticeState == PracticeState.Due && c.Due < tomorrow && !Objects.Select(o => o.Id).Contains(c.Id)) .Take(loadCount); if (!fullLoad) { tableQuery = tableQuery.ShallowLoad(LazyLoader); } int loadedCount = await AddItemsAsync(tableQuery.OrderBy(c => c.Due)).ConfigureAwait(false); if (loadedCount < loadCount) { Status = ReviewStatus.MoveNextEndOfStore; } else if (fullLoad) { FurtherLoadedIndex = loadedCount - 1; } return(loadedCount > 0); }
protected async Task <bool> DoFirstLoadAsync() { int totalLoadCount = NewCardsLeft + IncrementalLoadMax; int fullLoadCount = Math.Min(totalLoadCount, IncrementalFurtherLoadMax); int shallowLoadCount = totalLoadCount - fullLoadCount; ITableQueryAsync <Card> tableQuery = Db.Table <Card>().Where(c => c.PracticeState == PracticeState.New).Take(fullLoadCount); tableQuery = Random ? tableQuery.OrderByRand() : tableQuery.OrderBy(c => c.Due); // Fully load up to IncrementalFurtherLoadMax items int loadedCount = await AddItemsAsync(tableQuery).ConfigureAwait(false); FurtherLoadedIndex = loadedCount - 1; if (shallowLoadCount > 0 && loadedCount == fullLoadCount) { tableQuery = Db.Table <Card>() .ShallowLoad(LazyLoader) .Where( c => c.PracticeState == PracticeState.New && !Objects.Select(o => o.Id).Contains(c.Id)) .Take(shallowLoadCount); tableQuery = Random ? tableQuery.OrderByRand() : tableQuery.OrderBy(c => c.Due); loadedCount += await AddItemsAsync(tableQuery).ConfigureAwait(false); } if (loadedCount < totalLoadCount) { Status = ReviewStatus.MoveNextEndOfStore; } return(loadedCount > 0); }