diff --git a/datanommer.commands/datanommer/commands/extract_users.py b/datanommer.commands/datanommer/commands/extract_users.py index 0ba452bf0..a4f33518d 100644 --- a/datanommer.commands/datanommer/commands/extract_users.py +++ b/datanommer.commands/datanommer/commands/extract_users.py @@ -51,25 +51,22 @@ def main(config_path, topic, category, force_schema): elif category: query = query.where(m.Message.category == category) - query = ( - query.join( - m.users_assoc_table, - and_( - m.Message.id == m.users_assoc_table.c.msg_id, - m.Message.timestamp == m.users_assoc_table.c.msg_timestamp, - ), - isouter=True, - ) - .where(m.users_assoc_table.c.msg_id.is_(None)) - .order_by(m.Message.timestamp) - ) + query = query.join( + m.users_assoc_table, + and_( + m.Message.id == m.users_assoc_table.c.msg_id, + m.Message.timestamp == m.users_assoc_table.c.msg_timestamp, + ), + isouter=True, + ).where(m.users_assoc_table.c.msg_id.is_(None)) total = m.session.scalar(query.with_only_columns(func.count(m.Message.id))) if not total: click.echo("No messages matched.") return - click.echo(f"Considering {total} messages") + query = query.order_by(m.Message.timestamp) + click.echo(f"Considering {total} message{'s' if total > 1 else ''}") for message in m.session.scalars(query): headers = message.headers diff --git a/datanommer.commands/tests/test_extract_users.py b/datanommer.commands/tests/test_extract_users.py index 27ca75a69..99a84e504 100644 --- a/datanommer.commands/tests/test_extract_users.py +++ b/datanommer.commands/tests/test_extract_users.py @@ -95,4 +95,4 @@ def test_extract_users_no_users(datanommer_models, mock_config, mock_init): sa.select(sa.func.count(m.users_assoc_table.c.msg_id)) ) assert users_count == 0 - assert result.output == "" + assert result.output == "Considering 1 message\n"