@@ -32,8 +32,9 @@ public ODataV2CuratedFeedController(
3232 IGalleryConfigurationService configurationService ,
3333 ISearchService searchService ,
3434 ICuratedFeedService curatedFeedService ,
35- IEntityRepository < Package > packagesRepository )
36- : base ( configurationService )
35+ IEntityRepository < Package > packagesRepository ,
36+ ITelemetryService telemetryService )
37+ : base ( configurationService , telemetryService )
3738 {
3839 _configurationService = configurationService ;
3940 _searchService = searchService ;
@@ -68,7 +69,7 @@ public IHttpActionResult Get(
6869 semVerLevelKey )
6970 . InterceptWith ( new NormalizeVersionInterceptor ( ) ) ;
7071
71- return QueryResult ( options , queryable , MaxPageSize ) ;
72+ return TrackedQueryResult ( options , queryable , MaxPageSize , customQuery : true ) ;
7273 }
7374
7475 // /api/v2/curated-feed/curatedFeedName/Packages/$count?semVerLevel=
@@ -108,7 +109,7 @@ public async Task<IHttpActionResult> FindPackagesById(
108109 var emptyResult = Enumerable . Empty < Package > ( ) . AsQueryable ( )
109110 . ToV2FeedPackageQuery ( GetSiteRoot ( ) , _configurationService . Features . FriendlyLicenses , semVerLevelKey ) ;
110111
111- return QueryResult ( options , emptyResult , MaxPageSize ) ;
112+ return TrackedQueryResult ( options , emptyResult , MaxPageSize , customQuery : false ) ;
112113 }
113114
114115 return await GetCore ( options , curatedFeedName , id , normalizedVersion : null , return404NotFoundWhenNoResults : false , semVerLevel : semVerLevel ) ;
@@ -153,6 +154,7 @@ private async Task<IHttpActionResult> GetCore(
153154 }
154155
155156 var semVerLevelKey = SemVerLevelKey . ForSemVerLevel ( semVerLevel ) ;
157+ bool ? customQuery = null ;
156158
157159 // try the search service
158160 try
@@ -169,6 +171,8 @@ private async Task<IHttpActionResult> GetCore(
169171 // If intercepted, create a paged queryresult
170172 if ( searchAdaptorResult . ResultsAreProvidedBySearchService )
171173 {
174+ customQuery = false ;
175+
172176 // Packages provided by search service
173177 packages = searchAdaptorResult . Packages ;
174178
@@ -177,15 +181,25 @@ private async Task<IHttpActionResult> GetCore(
177181
178182 if ( return404NotFoundWhenNoResults && totalHits == 0 )
179183 {
184+ _telemetryService . TrackODataCustomQuery ( customQuery ) ;
180185 return NotFound ( ) ;
181186 }
182187
183188 var pagedQueryable = packages
184189 . Take ( options . Top != null ? Math . Min ( options . Top . Value , MaxPageSize ) : MaxPageSize )
185190 . ToV2FeedPackageQuery ( GetSiteRoot ( ) , _configurationService . Features . FriendlyLicenses , semVerLevelKey ) ;
186191
187- return QueryResult ( options , pagedQueryable , MaxPageSize , totalHits , ( o , s , resultCount ) =>
188- SearchAdaptor . GetNextLink ( Request . RequestUri , resultCount , new { id } , o , s , semVerLevelKey ) ) ;
192+ return TrackedQueryResult (
193+ options ,
194+ pagedQueryable ,
195+ MaxPageSize ,
196+ totalHits ,
197+ ( o , s , resultCount ) => SearchAdaptor . GetNextLink ( Request . RequestUri , resultCount , new { id } , o , s , semVerLevelKey ) ,
198+ customQuery ) ;
199+ }
200+ else
201+ {
202+ customQuery = true ;
189203 }
190204 }
191205 catch ( Exception ex )
@@ -197,6 +211,7 @@ private async Task<IHttpActionResult> GetCore(
197211
198212 if ( return404NotFoundWhenNoResults && ! packages . Any ( ) )
199213 {
214+ _telemetryService . TrackODataCustomQuery ( customQuery ) ;
200215 return NotFound ( ) ;
201216 }
202217
@@ -205,7 +220,7 @@ private async Task<IHttpActionResult> GetCore(
205220 _configurationService . Features . FriendlyLicenses ,
206221 semVerLevelKey ) ;
207222
208- return QueryResult ( options , queryable , MaxPageSize ) ;
223+ return TrackedQueryResult ( options , queryable , MaxPageSize , customQuery ) ;
209224 }
210225
211226 // /api/v2/curated-feed/curatedFeedName/Packages(Id=,Version=)/propertyName
@@ -278,10 +293,13 @@ public async Task<IHttpActionResult> Search(
278293 var query = searchAdaptorResult . Packages ;
279294
280295 var semVerLevelKey = SemVerLevelKey . ForSemVerLevel ( semVerLevel ) ;
296+ bool ? customQuery = null ;
281297
282298 // If intercepted, create a paged queryresult
283299 if ( searchAdaptorResult . ResultsAreProvidedBySearchService )
284300 {
301+ customQuery = false ;
302+
285303 // Add explicit Take() needed to limit search hijack result set size if $top is specified
286304 var totalHits = query . LongCount ( ) ;
287305 var pagedQueryable = query
@@ -291,22 +309,32 @@ public async Task<IHttpActionResult> Search(
291309 _configurationService . Features . FriendlyLicenses ,
292310 semVerLevelKey ) ;
293311
294- return QueryResult ( options , pagedQueryable , MaxPageSize , totalHits , ( o , s , resultCount ) =>
295- {
296- // The nuget.exe 2.x list command does not like the next link at the bottom when a $top is passed.
297- // Strip it of for backward compatibility.
298- if ( o . Top == null || ( resultCount . HasValue && o . Top . Value >= resultCount . Value ) )
312+ return TrackedQueryResult (
313+ options ,
314+ pagedQueryable ,
315+ MaxPageSize ,
316+ totalHits ,
317+ ( o , s , resultCount ) =>
299318 {
300- return SearchAdaptor . GetNextLink (
301- Request . RequestUri ,
302- resultCount ,
303- new { searchTerm , targetFramework , includePrerelease } ,
304- o ,
305- s ,
306- semVerLevelKey ) ;
307- }
308- return null ;
309- } ) ;
319+ // The nuget.exe 2.x list command does not like the next link at the bottom when a $top is passed.
320+ // Strip it of for backward compatibility.
321+ if ( o . Top == null || ( resultCount . HasValue && o . Top . Value >= resultCount . Value ) )
322+ {
323+ return SearchAdaptor . GetNextLink (
324+ Request . RequestUri ,
325+ resultCount ,
326+ new { searchTerm , targetFramework , includePrerelease } ,
327+ o ,
328+ s ,
329+ semVerLevelKey ) ;
330+ }
331+ return null ;
332+ } ,
333+ customQuery ) ;
334+ }
335+ else
336+ {
337+ customQuery = true ;
310338 }
311339
312340 // If not, just let OData handle things
@@ -315,7 +343,7 @@ public async Task<IHttpActionResult> Search(
315343 _configurationService . Features . FriendlyLicenses ,
316344 semVerLevelKey ) ;
317345
318- return QueryResult ( options , queryable , MaxPageSize ) ;
346+ return TrackedQueryResult ( options , queryable , MaxPageSize , customQuery ) ;
319347 }
320348
321349 // /api/v2/curated-feed/curatedFeedName/Search()/$count?searchTerm=&targetFramework=&includePrerelease=
0 commit comments