element-hq / element-hq/synapse

Remove redundant db calls from Login rest endpoint

Open
#18,153 3 comments 0 reactions 0 assignees View on GitHub
O-Occasional S-Tolerable T-Enhancement
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

**Description:**

when I was testing the login endpoint I noticed in jaeger that it calls the db 2 times, the first db call to get the `name` and `password_hash` and in the second call it gets `deactivated` status. instead of making it two queries, I suggest to make it in one query.

here is a screenshot for you:

![Image](https://github.com/user-attachments/assets/c839c801-f431-4c8d-9894-3896b581ab29)

the suggested new query

```sql
SELECT name, password_hash, deactivated FROM users WHERE lower(name) = lower(name)
```

also, you should remove the `name` from the select query because you already have it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.