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

split up orders into three tabs: all, open, closed (63114) #234

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

Conversation

svenwey
Copy link
Collaborator

@svenwey svenwey commented Feb 28, 2025

At the moment, in the 'Laufende' Tab, as it was before, all orders with 0 hours booked onto them are filtered out. I left this as it is (now for the tab 'Alle'), but I don't understand 100% why this was implemented this way. I could also remove it, if this is desired.

Leave the property of filtering out orders which have 0 hours fo 'all' tab present
@svenwey svenwey requested a review from daniel-illi February 28, 2025 10:30
@svenwey svenwey self-assigned this Feb 28, 2025
@svenwey svenwey changed the title [63114] split up orders into three tabs: all, open, closed. split up orders into three tabs: all, open, closed (63114) Feb 28, 2025
@svenwey svenwey requested review from kronn and removed request for kronn and daniel-illi March 5, 2025 07:18
@svenwey
Copy link
Collaborator Author

svenwey commented Mar 5, 2025

Some new requirements were introduced, hence this is again wip.

@svenwey svenwey marked this pull request as draft March 5, 2025 13:42
@svenwey svenwey marked this pull request as ready for review March 6, 2025 08:54
@svenwey svenwey requested a review from kronn March 6, 2025 08:54
Copy link
Member

@kronn kronn left a comment

Choose a reason for hiding this comment

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

The direction is good in general. One method needed a little change to become more readable to me.

With a few tests, this is good to go.

Comment on lines +164 to +171
return orders if params[:status_preselection].blank?
if params[:status_preselection] == 'closed'
return orders.where(order_statuses: { closed: true })
.where(period.where_condition('closed_at'))
end
return unless params[:status_preselection] == 'in_progress'
orders.where(order_statuses: { closed: false })

Copy link
Member

Choose a reason for hiding this comment

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

This needs at least reformatting, let's see... If I reformat, I notice that we are checking the same param over and over, so I switched to a case (pun intended)

Suggested change
return orders if params[:status_preselection].blank?
if params[:status_preselection] == 'closed'
return orders.where(order_statuses: { closed: true })
.where(period.where_condition('closed_at'))
end
return unless params[:status_preselection] == 'in_progress'
orders.where(order_statuses: { closed: false })
case params[:status_preselection]
when nil, ""
orders
when 'closed'
orders.where(order_statuses: { closed: true })
.where(period.where_condition('closed_at'))
when 'in_progress'
orders.where(order_statuses: { closed: false })
end

This also nicely obsoletes the mixture of if and unless which made this an excellent cylon detector.

The first case could be a guard statement as well. My proposal is to keep this all at the same level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants