Add #empty? check to Organizations::Organization

What does this MR do?

Adds Organizations::Organization#empty? predicate: returns true when the organization has no groups and no projects. Intentionally extensible — as org-level entities are introduced, they can add themselves to this check.

Notes:

  1. We might want to extend the implementation of Organizations::Organization#empty? to include more sub-resources checks in the future, see Extend `Organizations::Organization#empty?` to ... (#596537)
  2. Tests were added for the .active scope, which is generated automatically by the enum defined in Organizations::Stateful (introduced in Add Organizations::Stateful concern with state ... (!230909 - merged) • Rémy Coutable • 19.0)

Queries

> Organizations::Organization.active.explain
  Organizations::Organization Load (7.9ms)  SELECT "organizations".* FROM "organizations" WHERE "organizations"."state" = 0
=> EXPLAIN SELECT "organizations".* FROM "organizations" WHERE "organizations"."state" = 0
                                            QUERY PLAN
---------------------------------------------------------------------------------------------------
 Index Scan using index_organizations_on_state on organizations  (cost=0.15..5.24 rows=5 width=42)
   Index Cond: (state = 0)
(2 rows)
Edited by Ahmed Hemdan

Merge request reports

Loading
Loading