guess moods according to user pref
This commit is contained in:
parent
c5c70c91ba
commit
94b6ef89dd
4 changed files with 10 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
module MoodsHelper
|
module MoodsHelper
|
||||||
def mode_for(mood)
|
def mode_for(mood, user)
|
||||||
if params[:guess] == "active"
|
if user.guess?
|
||||||
mood[:mode] || mood[:guess] || "unknown"
|
mood[:mode] || mood[:guess] || "unknown"
|
||||||
else
|
else
|
||||||
mood[:mode] || "unknown"
|
mood[:mode] || "unknown"
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
<% month[:weeks].each do |week| %>
|
<% month[:weeks].each do |week| %>
|
||||||
<div class="is-flex is-flex-direction-column is-flex-wrap-wrap mb-3">
|
<div class="is-flex is-flex-direction-column is-flex-wrap-wrap mb-3">
|
||||||
<% week.each do |mood| %>
|
<% week.each do |mood| %>
|
||||||
<% mode = mode_for(mood) %>
|
<% mode = mode_for(mood, Current.user) %>
|
||||||
<div data-image="<%= asset_path(mode + ".jpg") %>" data-mode="<%= mode %>" data-day="<%= l mood[:recorded_at].to_date %>" data-action="click->mood#updateDayInfo" title="<%= l(mood[:recorded_at].to_date) %> : <%= mode %>" class="day <%= mode %>"></div>
|
<div data-image="<%= asset_path(mode + ".jpg") %>" data-mode="<%= mode %>" data-day="<%= l mood[:recorded_at].to_date %>" data-action="click->mood#updateDayInfo" title="<%= l(mood[:recorded_at].to_date) %> : <%= mode %>" class="day <%= mode %>"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
5
db/migrate/20260226101258_add_guess_to_users.rb
Normal file
5
db/migrate/20260226101258_add_guess_to_users.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddGuessToUsers < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
add_column :users, :guess, :boolean, default: false
|
||||||
|
end
|
||||||
|
end
|
||||||
3
db/schema.rb
generated
3
db/schema.rb
generated
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2026_02_19_114040) do
|
ActiveRecord::Schema[8.0].define(version: 2026_02_26_101258) do
|
||||||
create_table "moods", force: :cascade do |t|
|
create_table "moods", force: :cascade do |t|
|
||||||
t.string "mode"
|
t.string "mode"
|
||||||
t.datetime "recorded_at"
|
t.datetime "recorded_at"
|
||||||
|
|
@ -48,6 +48,7 @@ ActiveRecord::Schema[8.0].define(version: 2026_02_19_114040) do
|
||||||
t.datetime "invitation_accepted_at"
|
t.datetime "invitation_accepted_at"
|
||||||
t.string "username", null: false
|
t.string "username", null: false
|
||||||
t.boolean "public", default: false
|
t.boolean "public", default: false
|
||||||
|
t.boolean "guess", default: false
|
||||||
t.index ["email_address"], name: "index_users_on_email_address", unique: true
|
t.index ["email_address"], name: "index_users_on_email_address", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue