Skip to content

Commit

Permalink
use text year
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Mar 7, 2024
1 parent 1e6b39e commit 1d5c745
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 2 additions & 3 deletions app/controllers/growth/controller/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ def growth_api(code, entity = nil)

Aim.where(id: aim_ids).map do |aim|
if current_user
sn = RailsGrowth::SerialNumberHelper.result(Time.current, aim.repeat_type)
au = current_user.aim_users.find_by(aim_id: aim.id, serial_number: sn)
aim_user = current_user.aim_users.find_or_initialize_by(aim_id: aim.id, **aim.sn)
aim_entity = current_user.aim_entities.find_by(aim_id: aim.id, serial_number: sn)
aim_entity.entity = entity
next if au&.task_done? && aim_entity
next if aim_user.task_done? && aim_entity
aim_log = aim_entity.aim_logs.build(aim_id: aim.id)
else
next unless aim.verbose
Expand Down
8 changes: 4 additions & 4 deletions app/models/growth/model/aim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def serial_number(now = Time.current)
when 'forever'
now.strftime('%Y%j%H%M%S%L')
when 'daily'
now.strftime('%Y%j')
{ text_day: now.strftime('%Y%j') }
when 'weekly'
now.strftime('%Y%U')
{ text_week: now.strftime('%Y%U') }
when 'monthly'
now.strftime('%Y%m')
{ text_month: now.strftime('%Y%m') }
when 'yearly'
now.strftime('%Y')
{ text_year: now.strftime('%Y') }
else
now.strftime('%Y%j%H%M%S%L')
end
Expand Down
1 change: 1 addition & 0 deletions app/models/growth/model/aim_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Model::AimUser

included do
attribute :text_year, :string
attribute :text_month, :string
attribute :state, :string, default: 'task_doing'
attribute :reward_amount, :integer, default: 0
attribute :aim_entities_count, :integer, default: 0
Expand Down

0 comments on commit 1d5c745

Please sign in to comment.