Rails アプリには、User モデルと Posts モデルがあります。
:post_rate
方法があります
def self.post_rate(month_start, month_end)
where('created_at >= ? AND <= ?', month_start, month_end).map { |p| p.created_at.beginning_of_day }.uniq.size.to_f / (month_start - month_end).to_f
end
これは、特定の期間にユーザーが投稿した日数の割合を示しています。
ユーザー表示ページで、ユーザーの投稿頻度を月ごとにまとめて表示したいと考えています。次のような配列が必要です。
['Month', 'Frequency'],
['Jan', 0.1],
['Feb', 0.5],
['Mar', 0.9],
etc..
(ラベルとタイトルが必要です)。
どうすればこれを達成できますか?
パフォーマンスに関してどのような考慮事項を考慮する必要がありますか?
ありがとう