@@ -116,27 +116,15 @@ SELECT top 1 * FROM c
116116 ORDER BY c.date DESC
117117 """ ) ;
118118
119- var feed = _everestingHOFContainer . GetItemQueryIterator < Newtonsoft . Json . Linq . JObject > (
119+ var feed = _everestingHOFContainer . GetItemQueryIterator < ActivityItemProjection > (
120120 queryDefinition : query
121121 ) ;
122122
123123 while ( feed . HasMoreResults )
124124 {
125125 var response = await feed . ReadNextAsync ( cancellationToken ) ;
126- if ( response . Count > 1 )
127- {
128- throw new Exception ( "Some unexpected count of items" ) ;
129- }
130-
131126 var item = response . Single ( ) ;
132-
133- var date = item [ "date" ] ;
134- if ( date is null || date . Type != Newtonsoft . Json . Linq . JTokenType . String )
135- {
136- throw new Exception ( ) ;
137- }
138-
139- return DateTime . ParseExact ( date . ToString ( ) , "yyyy-MM-dd" , null ) ;
127+ return item . Date ;
140128 }
141129
142130 throw new Exception ( "Can't get last synced date time" ) ;
@@ -153,9 +141,7 @@ private static IEnumerable<string> GetScriptParts(string html)
153141 var doc = new HtmlDocument ( ) ;
154142 doc . LoadHtml ( html ) ;
155143
156- var scripts = doc
157- . DocumentNode
158- . SelectNodes ( "//script" )
144+ var scripts = doc . DocumentNode . SelectNodes ( "//script" )
159145 ?? throw new Exception ( "No script tags found" ) ;
160146
161147 foreach ( var script in scripts )
@@ -215,7 +201,6 @@ private static JsonElement ParseActivitiesJsonFromFullScript(IEnumerable<string>
215201 throw new InvalidOperationException ( "no json" ) ;
216202 }
217203
218-
219204 private static JsonElement GetActivitiesArray ( JsonElement root ) => root . GetProperty ( "activities" ) ;
220205 private static int GetCurrentPage ( JsonElement root ) => root . GetProperty ( "currentPage" ) . GetInt32 ( ) ;
221206 private static int GetTotalPages ( JsonElement root ) => root . GetProperty ( "totalPages" ) . GetInt32 ( ) ;
@@ -252,4 +237,9 @@ private async Task StoreData(
252237 // Fire all requests in parallel
253238 await Task . WhenAll ( tasks ) ;
254239 }
240+
241+ private record ActivityItemProjection
242+ {
243+ public DateTime Date { get ; init ; }
244+ }
255245}
0 commit comments