From 870503bc085ee1aeb1fd2d66dbc9ba0134cada4e Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 2 Mar 2023 21:46:58 -0800 Subject: [PATCH] help verbiage --- app/controllers/basil_controller.rb | 13 +++- app/views/basil/help_rate.html.erb | 100 ++++++++++++++++++++++++++++ app/views/basil/index.html.erb | 4 ++ config/routes.rb | 2 + 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 app/views/basil/help_rate.html.erb diff --git a/app/controllers/basil_controller.rb b/app/controllers/basil_controller.rb index 06bbbb20..fd55a8b4 100644 --- a/app/controllers/basil_controller.rb +++ b/app/controllers/basil_controller.rb @@ -189,7 +189,7 @@ class BasilController < ApplicationController commission.update( completed_at: DateTime.current, - final_settings: JSON.parse(params.fetch(:settings, {})) + final_settings: JSON.parse(params[:settings]) ) # TODO: we should attach the S3 object to the commission.image attachment @@ -224,4 +224,15 @@ class BasilController < ApplicationController feedback = commission.basil_feedbacks.find_or_initialize_by(user: current_user) feedback.update!(score_adjustment: score_adjustment) end + + def help_rate + # Commissions without feedback: + reviewed_commission_ids = BasilFeedback.where(user: current_user) + .pluck(:basil_commission_id) + @commissions = BasilCommission.where.not(id: reviewed_commission_ids) + .where.not(completed_at: nil) + .order(created_at: :desc) + .limit(50) + .includes(:entity) + end end diff --git a/app/views/basil/help_rate.html.erb b/app/views/basil/help_rate.html.erb new file mode 100644 index 00000000..aea74187 --- /dev/null +++ b/app/views/basil/help_rate.html.erb @@ -0,0 +1,100 @@ +
+ <%= link_to 'Back to Basil', basil_path %> +
+ +
+ You have <%= pluralize @commissions.count, 'generated images' %> without feedback. + Feedback is optional but helps Basil understand what he does well and what he could improve on. + You can refresh the page at any time to clear all the ones you've rated. +
+ +<% if @commissions.empty? %> +
+

Hurrah, inbox zero!

+
+ <%= link_to "Request a commission", basil_path, class: "btn purple" %> +
+<% end %> + +<% @commissions.each do |commission| %> +
+ <% if commission.complete? %> + <% + s3 = Aws::S3::Resource.new(region: "us-east-1") + obj = s3.bucket("basil-characters").object("job-#{commission.job_id}.png") + %> +
+
+ <%= link_to obj.presigned_url(:get) do %> + <%= image_tag obj.presigned_url(:get) %> + <% end %> +
+
+
+
+ <%= commission.entity.name %> + <% if commission.style? %> + (<%= commission.style.humanize %>) + <% end %> +
+
+ Completed <%= time_ago_in_words commission.completed_at %> ago + ·
+ Took <%= distance_of_time_in_words commission.completed_at - commission.created_at %> +
+
+
Feedback for Basil
+
+ <%= form_for commission.basil_feedbacks.find_or_initialize_by(user: current_user), url: basil_feedback_path(commission.job_id), method: :POST, remote: true do |f| %> +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ <% end %> +
+
+
+
+
+ <% else %> +
+ Basil is still working on this commission... (style: <%= commission.style %>) +
+ (Requested <%= time_ago_in_words(commission.created_at) %> ago) +
+
+ <% end %> +
+<% end %> diff --git a/app/views/basil/index.html.erb b/app/views/basil/index.html.erb index fd061d2a..e564d345 100644 --- a/app/views/basil/index.html.erb +++ b/app/views/basil/index.html.erb @@ -9,6 +9,10 @@ To get started, select the character you want to generate art for. Their description will be pulled from any answers you've given to questions in their "Looks" category.

+

+ NEW: You can also + <%= link_to 'help me get better by leaving feedback', basil_rating_queue_path %>. +

diff --git a/config/routes.rb b/config/routes.rb index dcae9058..25c1ce34 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,8 @@ Rails.application.routes.draw do post '/complete/:jobid', to: 'basil#complete_commission' post '/feedback/:jobid', to: 'basil#feedback', as: :basil_feedback + get '/help/rate', to: 'basil#help_rate', as: :basil_rating_queue + get '/info', to: 'basil#info' get '/review', to: 'basil#review' end