Exclude project bot from .com license seat
What does this MR do?
Project Bot users are to not be included in license: &2587
This MR excludes Project Bot users in .com
licenses.
They have been excluded in the self-managed licenses: https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/models/ee/user.rb#L275
Mentions #212888 (closed)
Database changes:
Query for billable project members:
SELECT
"members".*
FROM
"members"
LEFT OUTER JOIN "users" ON "members"."user_id" = "users"."id"
WHERE
"members"."type" = 'ProjectMember'
AND "members"."source_type" = 'Project'
AND "users"."state" = 'active'
AND "members"."requested_at" IS NULL
AND ("users"."user_type" IS NULL
OR "users"."user_type" != 6)
AND "members"."source_id" IN (
SELECT
"projects"."id"
FROM
"projects"
INNER JOIN "namespaces" ON "namespaces"."id" = "projects"."namespace_id"
AND "namespaces"."type" = 'Group'
WHERE
"projects"."namespace_id" IN ( WITH RECURSIVE "base_and_descendants" AS (
(
SELECT
"namespaces".*
FROM
"namespaces"
WHERE
"namespaces"."type" = 'Group'
AND "namespaces"."id" = 9970)
UNION (
SELECT
"namespaces".*
FROM
"namespaces",
"base_and_descendants"
WHERE
"namespaces"."type" = 'Group'
AND "namespaces"."parent_id" = "base_and_descendants"."id"))
SELECT
id
FROM
"base_and_descendants" AS "namespaces"))
Before optimizations
Query time:
Time: 4.623 s
- planning: 2.964 ms
- execution: 4.620 s
- I/O read: 4.575 s
- I/O write: 0.000 ms
Shared buffers:
- hits: 7353 (~57.40 MiB) from the buffer pool
- reads: 3267 (~25.50 MiB) from the OS file cache, including disk I/O
- dirtied: 85 (~680.00 KiB)
- writes: 0
Execution plan: https://explain.depesz.com/s/RV07
(#database-lab: https://gitlab.slack.com/archives/CLJMDRD8C/p1589297030240600)
After optimizations
Query time (Cold cache):
Time: 1.744 s
- planning: 3.205 ms
- execution: 1.740 s
- I/O read: 1.698 s
- I/O write: 0.000 ms
Shared buffers:
- hits: 7429 (~58.00 MiB) from the buffer pool
- reads: 3152 (~24.60 MiB) from the OS file cache, including disk I/O
- dirtied: 84 (~672.00 KiB)
- writes: 0
Execution plan: https://explain.depesz.com/s/LQHY
(#database-lab: https://gitlab.slack.com/archives/CLJMDRD8C/p1589558854031800)
Query time (warm cache):
Time: 16.158 ms
- planning: 2.852 ms
- execution: 13.306 ms
- I/O read: 0.000 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 10574 (~82.60 MiB) from the buffer pool
- reads: 0 from the OS file cache, including disk I/O
- dirtied: 0
- writes: 0
(#database-lab: https://gitlab.slack.com/archives/CLJMDRD8C/p1589559447034400)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team