-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Nuke empty communities from db #3401
Nuke empty communities from db #3401
Conversation
Can one of the admins verify this patch? |
1 similar comment
Can one of the admins verify this patch? |
quit() | ||
|
||
with db: | ||
cur.execute('SELECT group_id FROM groups;') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can extend this query to the following to not need the check in the for
loop:
SELECT g.group_id FROM groups g
WHERE (SELECT count(*) from group_users u WHERE g.group_id = u.group_id) = 0
Thanks for pointing this out. |
Does it works when using PostgreSQL through UNIX socket? I believe not, because you are forcing the use of too many parameters for this case. |
I don't have much PostgreSQL knowledge. |
AFAIK only dbname is required, because you can use |
…rg#3023 if run perpetually
c56c5a4
to
b3de5ed
Compare
@@ -1,33 +1,49 @@ | |||
#!/usr/bin/env python2 | |||
|
|||
from sys import argv | |||
from getopt import getopt | |||
import sqlite3 | |||
import psycopg2 | |||
|
|||
if len(argv) < 3 or (argv[1] != "sqlite" and argv[1] != "postgresql") or (argv[1] == "postgresql" and len(argv) < 6): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the 6
at the end of this line still makes options mandatory in practice.
Woops forget that line |
What exactly is the Synapse Sytest? |
Codecov Report
@@ Coverage Diff @@
## develop #3401 +/- ##
==========================================
Coverage ? 75.16%
==========================================
Files ? 340
Lines ? 34811
Branches ? 5701
==========================================
Hits ? 26166
Misses ? 7033
Partials ? 1612 |
should i move this script to contrib folder? |
Wouldn't it be a lot better if we stick to prepared states instead of executing MySQL Strings? |
There is an API to delete groups now so this script probably isn't needed anymore https://github.com/matrix-org/synapse/blob/master/docs/admin_api/delete_group.md |
The api only deletes single groups by id. This script scans the database for empty groups and deletes them. This script still serves an unique function but needs to be updated to use the new api. |
Thinking about the new api this would actually limit the script funtionality. The api uses a http interface, so it can only be used while the server is running. This script can be directly executed on the database of an online or offline instance. Also, the api currently only supports deleting groups, not to search all groups and select them according to members count. The script still needs to issue sql statements even when using the api. |
Made obsolete by: #6453 |
A script that helps keeping the homeserver clean from empty communities.
Related to issue #3023.
Developer Certificate of Origin
Version 1.1
Signed-off-by: Werner Sembach <werner.sembach at fau.de>