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

Developer filters - hourly rate, salary, and time zone #225

Merged
merged 5 commits into from Jan 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev
Use Ruby 2.7 beginless ranges for querying
  • Loading branch information
joemasilotti committed Jan 8, 2022
commit c6bc565e9afa72994135f1810f0f5c8eba225c98
@@ -24,10 +24,10 @@ class Developer < ApplicationRecord
validates :preferred_max_salary, allow_nil: true, numericality: {greater_than_or_equal_to: :preferred_min_salary}, if: -> { preferred_min_salary.present? }

scope :filter_by_utc_offset, ->(utc_offset) { where(utc_offset: utc_offset) }
scope :filter_by_hourly_rate, ->(hourly_rate) { where("preferred_min_hourly_rate <= ?", hourly_rate) }
scope :filter_by_salary, ->(salary) { where("preferred_min_salary <= ?", salary) }
scope :filter_by_hourly_rate, ->(hourly_rate) { where(preferred_min_hourly_rate: ..hourly_rate) }
scope :filter_by_salary, ->(salary) { where(preferred_min_salary: ..salary) }

scope :available, -> { where("available_on <= ?", Date.today) }
scope :available, -> { where(available_on: ..Time.current.to_date) }
scope :newest_first, -> { order(created_at: :desc) }
scope :available_first, -> { where.not(available_on: nil).order(:available_on) }