Skip to content

Commit

Permalink
Fix DABBLE-ME-5E
Browse files Browse the repository at this point in the history
  • Loading branch information
parterburn committed Feb 9, 2024
1 parent dc13bd2 commit d055ae6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/controllers/entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def index
if params[:emotion].present?
@entries = current_user.entries.includes(:inspiration).where("sentiment::text LIKE '%#{params[:emotion]}%'")
@title = "Entries tagged with #{params[:emotion].titleize}"
elsif params[:group] == "emotion"
elsif params[:group] == "emotion" && params[:subgroup].present? && params[:subgroup] =~ /^\d+$/
@entries = current_user.entries.includes(:inspiration).where("date >= '#{params[:subgroup]}-01-01'::DATE").where.not(sentiment: []).and(current_user.entries.where.not(sentiment: ["unknown"])).sort_by(&:date)
@title = "Entries tagged with Sentiment in #{params[:subgroup]}"
elsif params[:group] == 'photos'
Expand All @@ -16,7 +16,7 @@ def index
elsif params[:group] == 'ai'
@entries = current_user.entries.includes(:inspiration).with_ai_responses
@title = 'DabbleMeGPT Entries'
elsif params[:subgroup].present?
elsif params[:subgroup].present? && params[:group].present? && params[:subgroup] =~ /^\d+$/ && params[:group] =~ /^\d+$/
from_date = "#{params[:group]}-#{params[:subgroup]}"
to_date = Date.parse(from_date + "-01").end_of_month
@entries = current_user.entries.includes(:inspiration).where("date >= to_date('#{from_date}','YYYY-MM') AND date <= to_date('#{to_date}','YYYY-MM-DD')").sort_by(&:date)
Expand All @@ -35,6 +35,9 @@ def index
elsif params[:format] != "json"
@entries = current_user.entries.includes(:inspiration)
@title = 'All Entries'
else
flash[:alert] = "Page not accessible."
redirect_to root_path and return
end

if @entries.present?
Expand Down

0 comments on commit d055ae6

Please sign in to comment.