Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added sales total by products #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

styrken
Copy link

@styrken styrken commented Aug 4, 2022

No description provided.

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is helpful. We need some test and eager loading would be necessary to prevent a N+1 query

<tr>
<td><%= currency %></td>
<td>
<% if (variant = ::Spree::Variant.where(id: variant_id).first) %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we eager load in the controller this to prevent a N+1 query here, please?

@@ -6,6 +6,8 @@
collection do
get :sales_total
post :sales_total
get :sales_total_by_product
post :sales_total_by_product
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we would need the post route here.

<% admin_breadcrumb(link_to t('spree.reports'), spree.admin_reports_path) %>
<% admin_breadcrumb(t('spree.sales_total_by_product')) %>

<% content_for :page_actions do %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This empty block can be omitted

</tbody>
</table>
<div style="text-align: center">
<i>Not including tax, shipping, and adjustments</i>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we translate this note, please?

@totals[order.currency][:sales_total] += line_item.display_amount.money
end
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to see a spec for this

def sales_total
params[:q] = search_params

@search = Order.complete.not_canceled.ransack(params[:q])
@search = Order.complete.not_canceled.where(payment_state: "paid").ransack(params[:q])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to break the existing specs.

@orders = @search.result

Rails.logger.info("Orders Total: #{@orders.count}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be removed?

@tvdeyen tvdeyen added the help wanted Extra attention is needed label Oct 13, 2022
@stale
Copy link

stale bot commented Jan 7, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants