@@ -46,7 +46,9 @@ class UserInfo:
46
46
ips : List [str ] = attr .Factory (list )
47
47
48
48
49
- def get_recent_users (txn : LoggingTransaction , since_ms : int ) -> List [UserInfo ]:
49
+ def get_recent_users (
50
+ txn : LoggingTransaction , since_ms : int , exclude_app_service : bool
51
+ ) -> List [UserInfo ]:
50
52
"""Fetches recently registered users and some info on them."""
51
53
52
54
sql = """
@@ -56,6 +58,9 @@ def get_recent_users(txn: LoggingTransaction, since_ms: int) -> List[UserInfo]:
56
58
AND deactivated = 0
57
59
"""
58
60
61
+ if exclude_app_service :
62
+ sql += " AND appservice_id IS NULL"
63
+
59
64
txn .execute (sql , (since_ms / 1000 ,))
60
65
61
66
user_infos = [UserInfo (user_id , creation_ts ) for user_id , creation_ts in txn ]
@@ -113,14 +118,20 @@ def main() -> None:
113
118
"-e" ,
114
119
"--exclude-emails" ,
115
120
action = "store_true" ,
116
- help = "Exclude users that have validated email addresses" ,
121
+ help = "Exclude users that have validated email addresses. " ,
117
122
)
118
123
parser .add_argument (
119
124
"-u" ,
120
125
"--only-users" ,
121
126
action = "store_true" ,
122
127
help = "Only print user IDs that match." ,
123
128
)
129
+ parser .add_argument (
130
+ "-a" ,
131
+ "--exclude-app-service" ,
132
+ help = "Exclude appservice users." ,
133
+ action = "store_true" ,
134
+ )
124
135
125
136
config = ReviewConfig ()
126
137
@@ -133,6 +144,7 @@ def main() -> None:
133
144
134
145
since_ms = time .time () * 1000 - Config .parse_duration (config_args .since )
135
146
exclude_users_with_email = config_args .exclude_emails
147
+ exclude_users_with_appservice = config_args .exclude_app_service
136
148
include_context = not config_args .only_users
137
149
138
150
for database_config in config .database .databases :
@@ -143,7 +155,7 @@ def main() -> None:
143
155
144
156
with make_conn (database_config , engine , "review_recent_signups" ) as db_conn :
145
157
# This generates a type of Cursor, not LoggingTransaction.
146
- user_infos = get_recent_users (db_conn .cursor (), since_ms ) # type: ignore[arg-type]
158
+ user_infos = get_recent_users (db_conn .cursor (), since_ms , exclude_users_with_appservice ) # type: ignore[arg-type]
147
159
148
160
for user_info in user_infos :
149
161
if exclude_users_with_email and user_info .emails :
0 commit comments