Currently uc_reports_products / uc_reports_customers / uc_reports_sales_summary are monolithic functions that do all of the querying to create a data structure, then call theme functions and return formatted output. These fucntions could be re-usable for other purposes ( eg reporting apis ) if they are re-factored, for example:
function _uc_reports_products() {}
^^ This function does al the heavy-lifting and generates a data structure.
function uc_reports_products() {}
^^ This function is a basic wrapper that just calls _uc_reports_products, then uses the returned data structure and cals the theme functions.
This way, if I want to create a callback that returns a product sales report as JSON data, I can just call _uc_reports_products() directly instead of having to eg copy the entire function over into a custom module.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | export-of-uc_customers_report.txt | 18.84 KB | bisonbleu |
| #9 | uc_reports_product_report_view.txt | 31.67 KB | goodeit |
Comments
Comment #1
rszrama commentedTell me about it. That module's SQL is horrible, too. We just need a full replacement of the reports module. : )
I'm going to postpone this due to our place in the release cycle, not because it's a bad idea. Thanks for the feedback!
Comment #2
tr commentedReopening the issue so it can be addressed for the next major release.
Comment #3
longwaveMarked #1015056: Sales Report: Show separate line item for recurring monthly as duplicate. It would be good to either build the reports entirely with Views, or at least add some hooks and make that SQL less horrible.
Comment #4
tr commenteduc_reports was created because Ubercart needed reports and back then Views didn't support queries on arbitrary tables. Since orders aren't nodes, Views was useless for this purpose. Times have changed though and Views is far more capable. Ubercart gets constant requests for "add this type of report", or "I need another column for this report", or "please add a hook into report generation" etc. So we have a choice of either creating a general-purpose report builder UI, or switching all reports to Views and getting this for free. I vote for the latter :-).
I suggest that Ubercart 3.x should come with a set of pre-built Views replicating the familiar reports from Ubercart 2.x, then we can throw away uc_reports.
Comment #5
tr commentedComment #6
tr commentedComment #7
giorgio79 commentedYou could also make each order a node, with an order content type :)
Comment #8
tr commented@giorgio79: Orders are already Entities in D7. The only blocker on this issue is someone to devote time to creating the views and integrating them into uc_reports in place of the existing ad hoc solution.
Comment #9
goodeit commentedHere's a view that I put together real fast to emulate the product report in uc_reports. It has sorting by role added, but doesn't have any kind of date filter.
I haven't tested this thoroughly, but wanted to share in case it could help someone.
Comment #10
DanZ commentedThis still needs to be done.
There may be some steps still required before all the Views can be constructed. For instance, #1876496: Calculate additional Ordered Product fields for Views was needed for per-product sales breakdowns and #1490632: Expose payment receipts and payment balance to Views was needed for some accounting.
Are any other data sources still required? A key point is that normal Views aggregation (SUM(), GROUP BY) does not work on computed fields.
Also, the current reports provide CSV files, which are essential. Views does not do this out of the box, but instead relies on add-on modules such as Views Data Export. How should Ubercart deal with this?
Comment #11
longwaveI think this really just needs someone to spend the time trying to build the reports in Views and seeing what's not yet possible.
Regarding the CSV files we can just suggest that people install Views Data Export if they don't have it but they would like to export their reports, and add the relevant displays to the views when the module is installed. This is technically a regression but unless we package Data Export with Ubercart (which is a terrible idea) there is no way round it.
Comment #12
tr commentedWill implement in 8.x-4.x first then backport to 7.x-3.x. This will never be backported to 6.x-2.x.
Comment #13
tr commentedMarking #1472748: Different csv data in product report <> custom product report as a duplicate, because that won't be an issue anymore when reports are provided through Views.
Comment #14
tr commentedMarking #708932: Reports don't show multiple currencies as a duplicate.
We must ensure currency is shown in the new Views reports.
Comment #15
bisonbleu commentedFollowing up on #2877465: Displaying the Customer report stalls for 10,000 customers with multiple orders
Here is a Views version of Ubercart's core Customers Report (User).
It was built using views-7.x-3.14 and Ubercart 7.x-3.9 just because I have such an environment where I could test it. Let me know if this is OK or if I should upgrade to latest releases 7.x or 8.x. I'll wait a little for comments before tackling the next reports.
The only thing missing: Export to CSV file. and Show all records which I guess could be handled by views_data_export
Comment #16
bisonbleu commentedChanging back to Active.
Comment #17
tr commentedBump.