Skip to content

Commit b293f62

Browse files
committed
default stats to basil v2
1 parent 70e2ba5 commit b293f62

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

app/controllers/basil_controller.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,11 @@ def commission_info
256256
end
257257

258258
def stats
259-
@commissions = BasilCommission.all.with_deleted
259+
@version = params[:v] || 2
260+
@all_commissions = BasilCommission.where(basil_version: @version).with_deleted
260261

261-
@queued = BasilCommission.where(completed_at: nil)
262-
@completed = BasilCommission.where.not(completed_at: nil).with_deleted
262+
@queued = BasilCommission.where(completed_at: nil, basil_version: @version)
263+
@completed = BasilCommission.where.not(completed_at: nil).where(basil_version: @version).with_deleted
263264

264265
@average_wait_time = @completed.where('completed_at > ?', 24.hours.ago)
265266
.average(:cached_seconds_taken) || 0
@@ -268,10 +269,10 @@ def stats
268269
.map { |minutes, list| [minutes, list.count] }
269270

270271
# Projected date, at our current rate, to reach 1,000,000 images
271-
commission_counts_per_day = @commissions.group_by_day(:completed_at).values
272-
@average_commissions_per_day = commission_counts_per_day.sum(0.0) / commission_counts_per_day.count
273-
commissions_left = 1_000_000 - @commissions.count
274-
@days_til_1_million_commissions = commissions_left / @average_commissions_per_day
272+
commission_counts_per_day = @all_commissions.group_by_day(:completed_at).values
273+
@average_commissions_per_day = commission_counts_per_day.sum(0.0) / (commission_counts_per_day.count + 0.000001)
274+
commissions_left = 1_000_000 - @all_commissions.count
275+
@days_til_1_million_commissions = commissions_left / (@average_commissions_per_day + 0.000001)
275276

276277
# Feedback today
277278
@feedback_today = BasilFeedback.where('updated_at > ?', 24.hours.ago)

app/views/basil/stats.html.erb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<h1 style="font-size: 2em; margin-left: 1rem">Hey, I'm Basil.</h4>
77
<h2 style="font-size: 1.4em; margin-left: 1rem">I can help you visualize your ideas.</h2>
88
<p style="margin-left: 1rem">
9-
This is a little About Me page.
9+
<strong>The latest Basil version is v2.</strong> This page is currently showing stats for v<%= @version %>. You can see v1's stats by <%= link_to 'clicking here', basil_stats_path(v: 1) %>.
10+
<br /><br />
1011
<%= link_to 'Click here to start generating images of your notebook pages.', basil_path %>
1112
</p>
1213
</div>
@@ -37,12 +38,12 @@
3738
</div>
3839

3940
<div class="col s12 m4 l3">
40-
<h1 class="center purple-text" style="margin-bottom: 0; margin-top: 1.6em"><%= number_with_delimiter @commissions.count %></h1>
41+
<h1 class="center purple-text" style="margin-bottom: 0; margin-top: 1.6em"><%= number_with_delimiter @all_commissions.count %></h1>
4142
<div class="center grey-text"><strong>total images created</strong></div>
4243
</div>
4344
<div class="col s12 m8 l9 grey lighten-3">
4445
<%=
45-
area_chart @commissions.where('created_at > ?', 30.days.ago.beginning_of_month).group_by_day(:created_at).map { |date, count| [date.to_date, count] },
46+
area_chart @all_commissions.where('created_at > ?', 30.days.ago.beginning_of_month).group_by_day(:created_at).map { |date, count| [date.to_date, count] },
4647
colors: ['#9C27B0', '#2196F3'],
4748
title: 'Images created per day',
4849
suffix: ' images'

config/initializers/devise.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
# Time interval you can reset your password with a reset password key.
192192
# Don't put a too small interval or your users won't have the time to
193193
# change their passwords.
194-
config.reset_password_within = 6.hours
194+
config.reset_password_within = 48.hours
195195

196196
# When set to false, does not sign a user in automatically after their password is
197197
# reset. Defaults to true, so a user is signed in automatically after a reset.

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2023_05_12_222601) do
13+
ActiveRecord::Schema.define(version: 2025_05_06_081045) do
1414

1515
create_table "active_storage_attachments", force: :cascade do |t|
1616
t.string "name", null: false
@@ -201,6 +201,7 @@
201201
t.string "s3_bucket", default: "basil-commissions"
202202
t.datetime "saved_at"
203203
t.datetime "deleted_at"
204+
t.integer "basil_version", default: 2
204205
t.index ["entity_type", "entity_id", "saved_at"], name: "basil_commissions_ees"
205206
t.index ["entity_type", "entity_id", "style"], name: "basil_commissions_ees2"
206207
t.index ["entity_type", "entity_id"], name: "basil_commissions_ee"

0 commit comments

Comments
 (0)