# Problema ao acessar preferências após atualização para Discourse 2.1.0.beta4

**URL:** https://meta.discourse.org/t/trouble-accessing-preferences-after-upgrade-to-discourse-2-1-0-beta4/94253
**Category:** Bug
**Created:** [8 Agosto , 2018 22:18 UTC](https://meta.discourse.org/t/trouble-accessing-preferences-after-upgrade-to-discourse-2-1-0-beta4/94253 "2018-08-08T22:18:17Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [8 Agosto , 2018 22:18 UTC](https://meta.discourse.org/t/trouble-accessing-preferences-after-upgrade-to-discourse-2-1-0-beta4/94253/1 "2018-08-08T22:18:17Z")

</div>

I just updated a site and now I’m not able to access /my/preferences/account. I get `Server Error while trying to load /user-badges/jayp.json Error code: 504 Gateway Time-out`

I tried [safe mode](https://meta.discourse.org/t/53504?silent=true), and removed the only non-standard plugin (retort).

Though other users do seem to be able to access their preferences. Many are complaining about group-based theme modifications not working, so it seems that there might be some problem with groups.

Other pages seem to load fine, however. I don’t see anything in the logs in the web interface and don’t see it in the rails logs either.

I cannot replicate this here or on another site that I upgraded today.

EDIT: My current guess is that the problem has to do with some custom badge. There are many of them, but they aren’t SQL badges, and now that I see that, the badge hypothesis doesn’t make much sense.

```plaintext
method=GET path=/user-badges/jayp.json format=json controller=UserBadgesController action=username status=200 duration=5684.38 view=0.10 db=5577.50 params=_=1533766004403&username=jayp database=default db_calls=111 redis=0.73 redis_calls=6 ip=107.206.118.212 username=jayp

```

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [11 Agosto , 2018 03:02 UTC](https://meta.discourse.org/t/trouble-accessing-preferences-after-upgrade-to-discourse-2-1-0-beta4/94253/2 "2018-08-11T03:02:33Z")

</div>

> [@pfaffman](#):
>
> `db=5577.50 ... db_calls=111`

Now that’s a lot of queries …

Reproduced and checked locally, `UserSerializer` is making tons of SQL queries on the fly when serializing `user_badge.granted_by`.

I think `UserSerializer` is an overkill for the badges page, and `BasicUserSerializer` should do?

```diff
 class DetailedUserBadgeSerializer < BasicUserBadgeSerializer
- has_one :granted_by
+ has_one :granted_by, serializer: BasicUserSerializer

```

This cut down the number of queries from 81 to 8 locally for me.

Not too familiar with the badge-related pages, will dig a bit deeper to make sure this has no other side effects before submitting a PR.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [11 Agosto , 2018 03:11 UTC](https://meta.discourse.org/t/trouble-accessing-preferences-after-upgrade-to-discourse-2-1-0-beta4/94253/3 "2018-08-11T03:11:48Z")

</div>

> [@xrav3nz](#):
>
> side effects

Is that BasicUser as in Trust Level 1 ?

AFAIK, the number of Badges a New member can get is relatively few, and progressing to Basic member is not a high hurdle. Perhaps performance can be improved by taking New out of the query for those Badges that are impossible for a New member to get and running two queries instead?

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [11 Agosto , 2018 03:15 UTC](https://meta.discourse.org/t/trouble-accessing-preferences-after-upgrade-to-discourse-2-1-0-beta4/94253/4 "2018-08-11T03:15:35Z")

</div>

Oh no, it’s actually `Basic UserSerializer` instead of `BasicUser Serializer`.

i.e. it contains much less information about a user, but should be enough for the badges page.

Sorry about the confusion!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [11 Agosto , 2018 12:41 UTC](https://meta.discourse.org/t/trouble-accessing-preferences-after-upgrade-to-discourse-2-1-0-beta4/94253/5 "2018-08-11T12:41:11Z")

</div>

Hmm. If you’ve replicated this, I’m going to charge this to a bug. It started when upgrading to beta 3, I believe.

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [13 Agosto , 2018 19:29 UTC](https://meta.discourse.org/t/trouble-accessing-preferences-after-upgrade-to-discourse-2-1-0-beta4/94253/6 "2018-08-13T19:29:19Z")

</div>

As far as I can see, the change is safe. Just submitted a PR:

[https://github.com/discourse/discourse/pull/6266](https://github.com/discourse/discourse/pull/6266)

Didn’t test with previous versions, but I have a feeling that this has been like this for _a while_. The number of queries will only increase dramatically if a user has badges granted by different staff members.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [13 Agosto , 2018 20:28 UTC](https://meta.discourse.org/t/trouble-accessing-preferences-after-upgrade-to-discourse-2-1-0-beta4/94253/7 "2018-08-13T20:28:16Z")

</div>

@sam, you appear to be the last to have touched this in a meaningful way.

Oooh! And I can confirm that it fixes the site where I was previously unable to open preferences or preferences/badges.

Thanks, @xrav3nz!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [30 Agosto , 2018 03:14 UTC](https://meta.discourse.org/t/trouble-accessing-preferences-after-upgrade-to-discourse-2-1-0-beta4/94253/8 "2018-08-30T03:14:12Z")

</div>


