Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GitHub Mirror
mastodon
Mastodon
Commits
4a109ec1
Unverified
Commit
4a109ec1
authored
Nov 29, 2021
by
Jeong Arm
Committed by
GitHub
Nov 28, 2021
Browse files
Fix server graph on admin/tags/:id (#17066)
parent
af93d938
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/lib/admin/metrics/measure/tag_servers_measure.rb
View file @
4a109ec1
...
...
@@ -20,17 +20,20 @@ class Admin::Metrics::Measure::TagServersMeasure < Admin::Metrics::Measure::Base
def
data
sql
=
<<-
SQL
.
squish
SELECT axis.*, (
SELECT count(
*
) AS value
SELECT count(
distinct accounts.domain
) AS value
FROM statuses
WHERE statuses.id BETWEEN $1 AND $2
INNER JOIN statuses_tags ON statuses.id = statuses_tags.status_id
INNER JOIN accounts ON statuses.account_id = accounts.id
WHERE statuses_tags.tag_id = $1
AND statuses.id BETWEEN $2 AND $3
AND date_trunc('day', statuses.created_at)::date = axis.day
)
FROM (
SELECT generate_series(date_trunc('day', $
3
::timestamp)::date, date_trunc('day', $
4
::timestamp)::date, ('1 day')::interval) AS day
SELECT generate_series(date_trunc('day', $
4
::timestamp)::date, date_trunc('day', $
5
::timestamp)::date, ('1 day')::interval) AS day
) as axis
SQL
rows
=
ActiveRecord
::
Base
.
connection
.
select_all
(
sql
,
nil
,
[[
nil
,
Mastodon
::
Snowflake
.
id_at
(
@start_at
,
with_random:
false
)],
[
nil
,
Mastodon
::
Snowflake
.
id_at
(
@end_at
,
with_random:
false
)],
[
nil
,
@start_at
],
[
nil
,
@end_at
]])
rows
=
ActiveRecord
::
Base
.
connection
.
select_all
(
sql
,
nil
,
[[
nil
,
params
[
:id
].
to_i
],
[
nil
,
Mastodon
::
Snowflake
.
id_at
(
@start_at
,
with_random:
false
)],
[
nil
,
Mastodon
::
Snowflake
.
id_at
(
@end_at
,
with_random:
false
)],
[
nil
,
@start_at
],
[
nil
,
@end_at
]])
rows
.
map
{
|
row
|
{
date:
row
[
'day'
],
value:
row
[
'value'
].
to_s
}
}
end
...
...
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