Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7a943c60
Commit
7a943c60
authored
Mar 25, 2021
by
Alper Akgun
Committed by
Rajendra Kadam
Mar 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix usage data count start/finish export issue
parent
4ee871cb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
changelogs/unreleased/325884-usage-data-count-start-finish-problems.yml
...eleased/325884-usage-data-count-start-finish-problems.yml
+5
-0
lib/gitlab/usage_data_queries.rb
lib/gitlab/usage_data_queries.rb
+4
-4
spec/lib/gitlab/usage_data_queries_spec.rb
spec/lib/gitlab/usage_data_queries_spec.rb
+12
-0
No files found.
changelogs/unreleased/325884-usage-data-count-start-finish-problems.yml
0 → 100644
View file @
7a943c60
---
title
:
Fix usage data count start/finish export issue
merge_request
:
57403
author
:
type
:
fixed
lib/gitlab/usage_data_queries.rb
View file @
7a943c60
...
...
@@ -5,11 +5,11 @@ module Gitlab
# See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/41091
class
UsageDataQueries
<
UsageData
class
<<
self
def
count
(
relation
,
column
=
nil
,
*
rest
)
def
count
(
relation
,
column
=
nil
,
*
args
,
**
kwargs
)
raw_sql
(
relation
,
column
)
end
def
distinct_count
(
relation
,
column
=
nil
,
*
rest
)
def
distinct_count
(
relation
,
column
=
nil
,
*
args
,
**
kwargs
)
raw_sql
(
relation
,
column
,
:distinct
)
end
...
...
@@ -21,14 +21,14 @@ module Gitlab
end
end
def
sum
(
relation
,
column
,
*
rest
)
def
sum
(
relation
,
column
,
*
args
,
**
kwargs
)
relation
.
select
(
relation
.
all
.
table
[
column
].
sum
).
to_sql
end
# For estimated distinct count use exact query instead of hll
# buckets query, because it can't be used to obtain estimations without
# supplementary ruby code present in Gitlab::Database::PostgresHll::BatchDistinctCounter
def
estimate_batch_distinct_count
(
relation
,
column
=
nil
,
*
rest
)
def
estimate_batch_distinct_count
(
relation
,
column
=
nil
,
*
args
,
**
kwargs
)
raw_sql
(
relation
,
column
,
:distinct
)
end
...
...
spec/lib/gitlab/usage_data_queries_spec.rb
View file @
7a943c60
...
...
@@ -11,12 +11,24 @@ RSpec.describe Gitlab::UsageDataQueries do
it
'returns the raw SQL'
do
expect
(
described_class
.
count
(
User
)).
to
start_with
(
'SELECT COUNT("users"."id") FROM "users"'
)
end
it
'does not mix a nil column with keyword arguments'
do
expect
(
described_class
).
to
receive
(
:raw_sql
).
with
(
User
,
nil
)
described_class
.
count
(
User
,
start:
1
,
finish:
2
)
end
end
describe
'.distinct_count'
do
it
'returns the raw SQL'
do
expect
(
described_class
.
distinct_count
(
Issue
,
:author_id
)).
to
eq
(
'SELECT COUNT(DISTINCT "issues"."author_id") FROM "issues"'
)
end
it
'does not mix a nil column with keyword arguments'
do
expect
(
described_class
).
to
receive
(
:raw_sql
).
with
(
Issue
,
nil
,
:distinct
)
described_class
.
distinct_count
(
Issue
,
nil
,
start:
1
,
finish:
2
)
end
end
describe
'.redis_usage_data'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment