Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

management: Delete dump_messages command.

Gaurav Pandey7db3d76ecded
diff --git a/zerver/management/commands/dump_messages.py b/zerver/management/commands/dump_messages.py
deleted file mode 100644
index b451eb34ee0..00000000000
--- a/zerver/management/commands/dump_messages.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import datetime
-import time
-from typing import Any
-
-from django.core.management.base import CommandParser
-
-from zerver.lib.management import ZulipBaseCommand
-from zerver.models import Message, Recipient, Stream
-
-
-class Command(ZulipBaseCommand):
- help = "Dump messages from public streams of a realm"
-
- def add_arguments(self, parser: CommandParser) -> None:
- default_cutoff = time.time() - 60 * 60 * 24 * 30 # 30 days.
- self.add_realm_args(parser, required=True)
- parser.add_argument(
- "--since",
- type=int,
- default=default_cutoff,
- help="The time in epoch since from which to start the dump.",
- )
-
- def handle(self, *args: Any, **options: Any) -> None:
- realm = self.get_realm(options)
- streams = Stream.objects.filter(realm=realm, invite_only=False)
- recipients = Recipient.objects.filter(
- type=Recipient.STREAM, type_id__in=[stream.id for stream in streams]
- )
- cutoff = datetime.datetime.fromtimestamp(options["since"], tz=datetime.timezone.utc)
- messages = Message.objects.filter(date_sent__gt=cutoff, recipient__in=recipients)
-
- for message in messages:
- print(message.to_dict(False))