MushroomObserver / mushroom-observer

A website for sharing observations of mushrooms.
https://mushroomobserver.org
MIT License
77 stars 25 forks source link

nil user_stats for fresh User #2078

Closed JoeCohen closed 3 months ago

JoeCohen commented 3 months ago

Lately /user/nnnnnn throws errors for brand-new users. Example below. This is reproducible locally:


Cron Daemon to webmaster Mar 29, 2024, 11:08 AM [PDT] (19 hours ago)

INFO -- : Started GET "/users/170060" for 149.40.50.109 at 2024-03-29 18:07:52 +0000
INFO -- : Processing by UsersController#show as HTML
INFO -- :   Parameters: {"id"=>"170060"}
WARN -- : user=170060 robot=N ip=149.40.50.109
INFO -- :   Rendered layout controllers/layouts/application.html.erb (Duration: 11.0ms | Allocations: 2610)
INFO -- : Completed 500 Internal Server Error in 683ms (ActiveRecord: 645.5ms | Allocations: 9432)
E, [2024-03-29T18:07:53.652091 #540829] ERROR -- :   
ActionView::Template::Error (undefined method `checklist' for nil):
    12:     nil
    13:   end
    14: footer =
    15:   if @user_stats.checklist[:species].to_i > 0
    16:     [link_to(checklist_path(id: @[show_user.id](http://show_user.id/))) do
    17:        tag.strong(:app_life_list.t)
    18:      end, ": ",

app/views/controllers/users/show/_profile.erb:15
app/views/controllers/users/show.html.erb:15
app/controllers/application_controller.rb:226:in `catch_errors_and_log_request_stats'
JoeCohen commented 3 months ago

Note that the user_stats table allows null values for the languages, bonuses, and checklist columns.

JoeCohen commented 3 months ago

@nimmolo: Off the top of your head, do you think this is related to recent changes to site & user stats? (Cf. #2080)