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

Date range filter #37

Merged
merged 15 commits into from
Jan 11, 2025
Merged

Date range filter #37

merged 15 commits into from
Jan 11, 2025

Conversation

VoldemLive
Copy link
Collaborator

Add date filter to lab tests table

Changes Made

  • Added date filter form to lab tests index view
  • Implemented date range inputs (From/To)
  • Added filter submit button with Tailwind styling
  • Added translations for filter labels
  • Positioned filter controls above the lab tests table
  • Modified lab tests query to show latest results per day

Technical Details

  • Used Tailwind CSS for consistent styling
  • Implemented form_with for proper form handling
  • Added i18n translations under lab_tests.date_filter namespace
  • Maintained responsive layout with flex positioning
  • Used DISTINCT ON with PostgreSQL to get unique daily records
  • Optimized query to return latest test result when multiple tests exist per day
  • Ordered results chronologically (oldest to newest)

Files Changed

  • app/views/lab_tests/_date_filter.html.erb (new)
  • app/controllers/lab_tests_controller.rb (updated)
  • config/locales/en.yml (updated)

Database Query Optimization

  • Implemented DISTINCT ON to prevent duplicate dates
  • Added proper ordering to ensure latest results are selected
  • Maintained recordable_id for proper data relationships

@VoldemLive VoldemLive requested a review from aksafan January 6, 2025 19:22
@aksafan aksafan requested a review from Haothai1 January 6, 2025 20:20
app/controllers/lab_tests_controller.rb Outdated Show resolved Hide resolved
app/controllers/lab_tests_controller.rb Outdated Show resolved Hide resolved
app/controllers/lab_tests_controller.rb Outdated Show resolved Hide resolved
app/controllers/lab_tests_controller.rb Outdated Show resolved Hide resolved
app/controllers/lab_tests_controller.rb Outdated Show resolved Hide resolved
app/controllers/lab_tests_controller.rb Show resolved Hide resolved
app/controllers/lab_tests_controller.rb Outdated Show resolved Hide resolved
app/controllers/lab_tests_controller.rb Outdated Show resolved Hide resolved
app/views/lab_tests/_date_filter.html.erb Show resolved Hide resolved
app/views/lab_tests/index.html.erb Show resolved Hide resolved
@VoldemLive VoldemLive requested a review from aksafan January 8, 2025 23:18
Copy link
Collaborator

@aksafan aksafan left a comment

Choose a reason for hiding this comment

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

Like the usage of scope in model, look much-much more clear and maintainable.

app/controllers/lab_tests_controller.rb Outdated Show resolved Hide resolved
app/controllers/lab_tests_controller.rb Outdated Show resolved Hide resolved
app/models/lab_test.rb Outdated Show resolved Hide resolved
app/models/lab_test.rb Outdated Show resolved Hide resolved
app/models/lab_test.rb Outdated Show resolved Hide resolved
app/models/lab_test.rb Outdated Show resolved Hide resolved
config/application.rb Outdated Show resolved Hide resolved
config/locales/en.yml Show resolved Hide resolved
@VoldemLive
Copy link
Collaborator Author

about this
image

I am looking for a solution and I confirm on my side I still have commented authorization:
image

I merged with a develop branch, it told me: "Already up to date.". I will fix it by hand.

image

done. Let's check it on the next commit.

app/views/lab_tests/_date_filter.html.erb Show resolved Hide resolved
app/views/lab_tests/index.html.erb Show resolved Hide resolved
app/views/lab_tests/index.html.erb Show resolved Hide resolved
app/views/lab_tests/_no_data_placeholder.html.erb Outdated Show resolved Hide resolved
app/views/lab_tests/_date_filter.html.erb Outdated Show resolved Hide resolved
config/application.rb Show resolved Hide resolved
app/controllers/lab_tests_controller.rb Show resolved Hide resolved
@VoldemLive VoldemLive requested a review from aksafan January 11, 2025 05:52
Copy link
Collaborator

@aksafan aksafan left a comment

Choose a reason for hiding this comment

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

Well done!

@aksafan aksafan merged commit 4936834 into develop Jan 11, 2025
2 checks passed
@aksafan aksafan deleted the date_range_filter branch January 11, 2025 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants