Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
89834d9a
Commit
89834d9a
authored
6 years ago
by
Neil Johnson
Browse files
Options
Downloads
Plain Diff
Merge branch 'neilj/mau_tracker' of github.com:matrix-org/synapse into neilj/disable_hs
parents
7bcf126b
e54794f5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/monthly_active_users.py
+15
-4
15 additions, 4 deletions
synapse/storage/monthly_active_users.py
with
15 additions
and
4 deletions
synapse/storage/monthly_active_users.py
+
15
−
4
View file @
89834d9a
...
@@ -43,14 +43,25 @@ class MonthlyActiveUsersStore(SQLBaseStore):
...
@@ -43,14 +43,25 @@ class MonthlyActiveUsersStore(SQLBaseStore):
thirty_days_ago
=
(
thirty_days_ago
=
(
int
(
self
.
_clock
.
time_msec
())
-
(
1000
*
60
*
60
*
24
*
30
)
int
(
self
.
_clock
.
time_msec
())
-
(
1000
*
60
*
60
*
24
*
30
)
)
)
# Purge stale users
sql
=
"
DELETE FROM monthly_active_users WHERE timestamp < ?
"
sql
=
"
DELETE FROM monthly_active_users WHERE timestamp < ?
"
txn
.
execute
(
sql
,
(
thirty_days_ago
,))
txn
.
execute
(
sql
,
(
thirty_days_ago
,))
# If MAU user count still exceeds the MAU threshold, then delete on
# a least recently active basis.
# Note it is not possible to write this query using OFFSET due to
# incompatibilities in how sqlite an postgres support the feature.
# sqlite requires 'LIMIT -1 OFFSET ?', the LIMIT must be present
# While Postgres does not require 'LIMIT', but also does not support
# negative LIMIT values. So there is no way to write it that both can
# support
sql
=
"""
sql
=
"""
DELETE FROM monthly_active_users
DELETE FROM monthly_active_users
ORDER BY timestamp desc
WHERE user_id NOT IN (
LIMIT -1 OFFSET ?
SELECT user_id FROM monthly_active_users
ORDER BY timestamp DESC
LIMIT ?
)
"""
"""
txn
.
execute
(
sql
,
(
self
.
hs
.
config
.
max_mau_value
,))
txn
.
execute
(
sql
,
(
self
.
hs
.
config
.
max_mau_value
,))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment