11 Commits

Author SHA1 Message Date
Christophe Bliard be23b6e89b Fix error when users table does not exist (#21482)
* Fix error when users table does not exist

In multitenant context, when schema is switched to and the tables are
not created yet, getting `User.current` will fail with

    ActiveRecord::StatementInvalid:"PG::UndefinedTable: ERROR:  relation \"users\" does not exist" [...]

To prevent it, check if the table exists first and return `nil` if not.

* Avoid logging "slow sql" for database creation

* Better performance for handling unexisting users table

Checking multiple times the users table existence when something is
logged is probably a bad idea. Better rescue errors.

Also cache the return value of `#current_user` to call the method only
once.
2025-12-18 15:12:26 +01:00
Christophe Bliard b3992d9698 Avoid logging slow SQL for tenant creation 2025-09-30 17:53:41 +02:00
Alexander Brandon Coles 3eeb5abfab Fix missing copyright notices in config 2025-08-19 17:40:34 +01:00
Alexander Brandon Coles 78ed9ea580 Freeze string literals in config
rubocop -A --only Style/FrozenStringLiteralComment,Layout/EmptyLineAfterMagicComment,Style/RedundantFreeze config
2025-08-19 17:04:00 +01:00
Dombi Attila ba16112745 Use Rails.application instead of OpenProject::Application 2024-02-01 14:22:04 +02:00
Christophe Bliard 8fa8584538 Run rubocop --autocorrect on all files
Only the safe cops have run. rubocop version is 1.59.0.
2024-01-05 15:27:09 +01:00
Klaus Zanders 26cee2729e Fixes Performance/RegexpMatch offenses 2023-09-06 12:50:32 +02:00
Oliver Günther 16446cd80b Avoid logging with log delegator in migrations (#9150)
If the slow log catches during migrations, accessing something like
User.current will fail as not all tables are defined yet.
2021-04-12 11:49:11 +01:00
ulferts 1bdd2ab9ae safe automatic fixes by rubocop (#8994) 2021-02-11 16:02:18 +01:00
Oliver Günther d3ba1705e2 Skip slow log on test [ci skip] 2020-07-09 15:31:23 +02:00
Oliver Günther cbb04e3541 Allow logging slow SQL queries to sentry/local logger
We can use the activerecord.sql notification hook to determine slow
running queries without needing to look into the psql slow log.

The default threshold is set to 2000ms for now, can be changed freely with
`OPENPROJECT_SQL__SLOW__QUERY__THRESHOLD=X` where X is an integer
threshold in miliseconds
2020-06-26 10:51:53 +02:00