Repository navigation
Run the admin report queries asynchronously and page bestsellers in the aggregation - #972
Merged
Merged
Conversation
- Bestsellers and best customers sort with a unique tie-breaker, so pages paged in the aggregation no longer repeat or skip tied rows - Bestseller and vendor amounts divide by CurrencyRate, and the order-by-time report divides instead of multiplying, matching the other reports - Vendor country and best-customer reports count orders, not order items - By-time reports are sorted by time and include the whole end day - Registered customers report uses a UTC cutoff; customer-by-time report returns empty when the Registered group is missing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The admin reports executed their aggregations synchronously, and the bestsellers report paged in memory.
OrderReportServiceBestSellersReportread every product group of the unwind + group over the matching orders with a synchronous.ToList(), then paged the list in memory. The sort and the page now run in the aggregation throughPagedAsync, so only the requested page leaves the database.GetCountryReport,GetOrderByTimeReport,GetOrderAverageReportLineandGetOrderPeriodReportuse the repository's async reads instead of a synchronous.ToList()/.FirstOrDefault()wrapped inTask.FromResult.GetAlsoPurchasedProductsIdsreads only the product ids, asynchronously.ProductsNeverSoldloaded the product id of every order item and removed duplicates in memory. TheDistinct()now runs in the database, so only the unique sold ids come back.CustomerReportServiceGetBestCustomersReportalready pages in the aggregation (since Return pages instead of IQueryable from the Business queries #949) and is unchanged.GetRegisteredCustomersReportusesCountAsyncinstead ofCount(), andGetCustomerByTimeReportusesToListAsyncinstead of.ToList().Report fixes
Bugs in the same functions, fixed in a second commit:
ProductId/CustomerId). Without it, paging in the aggregation could show a tied row on two pages and skip another.CurrencyRateinstead ofRate.GetOrderByTimeReportmultiplied byCurrencyRate; it now divides, like every other report.GetCountryReportandGetBestCustomersReportcounted order items as orders. They now group by order first.GetOrderByTimeReportreturns its rows sorted by time. Both by-time reports end at the start of the next day instead of 23:59:00, so the last minute of the end day is included.GetRegisteredCustomersReportcomparedCreatedOnUtcwith a user-time cutoff; it now usesDateTime.UtcNow.GetCustomerByTimeReportreturns an empty report when the Registered group is missing instead of throwing.Reported amounts change in two cases: the bestseller and vendor amounts when the primary currency's rate is not 1.0, and the orders-by-time sums whenever orders were placed in a currency other than the primary one. They now match the other dashboard figures.
Not in this PR:
ProductsNeverSoldstill sends the sold product ids back in a$ninfilter, which can approach the 16MB document limit on a very large catalog. Replacing it needs an index or a different approach, so it is left for a follow-up.Measured
Not measured.
When a page comes back full,
PagedAsyncruns a count of the grouped query, so the bestsellers grouping runs twice: once for the page, once for the total. The admin grid needs that total. The storefront home page bestsellers widget does not use it, but it only calls the report on a cache miss.Breaking changes
None for callers: the service interfaces are unchanged.
CustomerReportServiceno longer takesIDateTimeServicein its constructor; DI resolves it unchanged, only directnewcalls need the argument removed.Testing
dotnet testonGrand.Business.Checkout.Tests(304 passed),Grand.Business.Customers.Tests(134 passed) andGrand.Web.Admin.Tests(1580 passed). New tests on the Mongo test repository cover: