Skip to content

Conversation

@amsak1983
Copy link
Owner

No description provided.

@test_passage.accept!(params[:answer_ids])

@test_passage.check_successful_completed!
if @test_passage.completed?

Choose a reason for hiding this comment

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

у тебя тут проверка завершения и внутри check_successful_completed. получается что ты два раза одно и тоже проверяешь - неоптимально. стоит из метода check_successful_completed убрать тогда проверку завершенности и переместить внутрь if

scope :hard, -> { where(level: :hard) }
scope :ready, -> { where(status: 1) }
scope :by_category, ->(category_title) { joins(:category).where(categories: { title: category_title }) }
scope :by_category, lambda { |category_title|

Choose a reason for hiding this comment

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

объясни логику этого метода?

1 - передали пустую строку - вернется пустой массив, зачем обработка return self unless category_title.present??
2 -

 sanitized_title = ActiveRecord::Base.sanitize_sql_like(category_title)
    joins(:category).where(Category.arel_table[:title].matches(sanitized_title))

какую проблему тут решаешь?

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.

3 participants