|
- # == Schema Information
- #
- # Table name: timeable_visit_records
- #
- # id :integer not null, primary key
- # time :string(255)
- # project_id :integer
- # visits :integer default("0")
- # created_at :datetime not null
- # updated_at :datetime not null
- #
- # Indexes
- #
- # index_timeable_visit_records_on_project_id (project_id)
- # index_timeable_visit_records_on_time (time)
- #
-
- class TimeableVisitRecord < ApplicationRecord
-
- belongs_to :project
-
- def self.build(project_id)
- week = TimeableVisitRecord.find_or_create_by!(time: Date.today.strftime("%Y-%W"), project_id: project_id)
- month = TimeableVisitRecord.find_or_create_by!(time: Date.today.strftime("%Y%m"), project_id: project_id)
-
- return week, month
- end
- end
|