# User card loading failed

**URL:** https://meta.discourse.org/t/user-card-loading-failed/366391
**Category:** Support
**Tags:** gamification, user-card
**Created:** [May 16, 2025, 7:53am UTC](https://meta.discourse.org/t/user-card-loading-failed/366391 "2025-05-16T07:53:49Z")
**Posts on this page:** 1
**Showing post:** 21

<div class="post-metadata">

### Author: ![selase](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/selase/32/270909_2.png) [@selase](https://meta.discourse.org/u/selase)
#### Post date: [May 19, 2025, 2:44pm UTC](https://meta.discourse.org/t/user-card-loading-failed/366391/21 "2025-05-19T14:44:45Z")

</div>

I don’t have the full trace, but I believe the error happens during `gamification_score` serialization for the user card.

Given the transient nature of these materialized views, a score lookup isn’t expected to cause a system-wide error, it should fall back to a “default score” when the view doesn’t exist.

There’s a bug in the materialized view [existence check](https://github.com/discourse/discourse-gamification/blob/213af96acc1ff24ba61b93dff1dcea2791154511/lib/discourse_gamification/leaderboard_cached_view.rb#L226-L232). It reports that a view exists when it actually doesn’t (at least not in the current `public` schema), which leads to a lookup on a non-existent view resulting in the error.

I think what happened here was, the materialized view was present in the `backup` schema created as part of the restore but not the `public` schema. The `backup` schema is retained for a while after the restore.

> <https://github.com/discourse/discourse-gamification/blob/213af96acc1ff24ba61b93dff1dcea2791154511/plugin.rb#L100>

> <https://github.com/discourse/discourse-gamification/blob/213af96acc1ff24ba61b93dff1dcea2791154511/lib/discourse_gamification/user_extension.rb#L15>

> <https://github.com/discourse/discourse-gamification/blob/213af96acc1ff24ba61b93dff1dcea2791154511/lib/discourse_gamification/leaderboard_cached_view.rb#L51-L68>

I’ve got a PR ready with a fix.

[https://github.com/discourse/discourse-gamification/pull/203](https://github.com/discourse/discourse-gamification/pull/203)

---

_[View the full topic](https://meta.discourse.org/t/user-card-loading-failed/366391)._
