Skip to content

Commit 37af32b

Browse files
author
Andrii Bondarchuk
committed
Use cosmosdb linq intead of pure query
1 parent 78181cb commit 37af32b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/FitSyncHub.Functions/Functions/EverestingHOFScraperHttpTriggerFunction.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.AspNetCore.Mvc;
1010
using Microsoft.AspNetCore.WebUtilities;
1111
using Microsoft.Azure.Cosmos;
12+
using Microsoft.Azure.Cosmos.Linq;
1213
using Microsoft.Azure.Functions.Worker;
1314
using Microsoft.Extensions.Logging;
1415
using Microsoft.Extensions.Primitives;
@@ -109,15 +110,10 @@ private static bool AllActiviesSynced(
109110

110111
private async Task<DateTime> GetLastSynchronizedDate(CancellationToken cancellationToken)
111112
{
112-
var query = new QueryDefinition(
113-
"""
114-
SELECT top 1 * FROM c
115-
ORDER BY c.date DESC
116-
""");
117-
118-
var feed = _everestingHOFContainer.GetItemQueryIterator<ActivityItemProjection>(
119-
queryDefinition: query
120-
);
113+
var feed = _everestingHOFContainer.GetItemLinqQueryable<ActivityItemProjection>()
114+
.OrderByDescending(x => x.Date)
115+
.Take(1)
116+
.ToFeedIterator();
121117

122118
while (feed.HasMoreResults)
123119
{

0 commit comments

Comments
 (0)