def METHOD_NAME(self, *args, **options):
    num_events = options.get('num')
    events_count = models.Event.objects.count()
    if num_events > events_count:
        num_events = events_count
    events = models.Event.objects.select_related('base__branch__repository__user__server',
        'head__branch__repository__user__server',
        'pull_request',
        'build_user'
        ).prefetch_related("jobs").order_by('created').all()[(events_count-num_events):]
    output_filename = options.get('output')
    indent = options.get('indent')
    collected = []
    self.stdout.write("Dumping %s events" % events.count())
    for e in events:
        self.add_event(e, collected)
    # This could pull in a lot of additional events so disable it for now
    #for pr in models.PullRequest.objects.filter(closed=False).all():
    #  self.add_obj(pr, collected)
    #  self.add_obj(pr.repository.user.server, collected)
    #  self.add_obj(pr.repository.user, collected)
    #  self.add_obj(pr.repository, collected)
    #  for e in pr.events.all():
    #    self.add_event(e, collected)
    for branch in models.Branch.objects.exclude(status=models.JobStatus.NOT_STARTED).select_related("repository__user__server").all():
        self.add_obj(branch.repository.user.server, collected)
        self.add_obj(branch.repository.user, collected)
        self.add_obj(branch.repository, collected)
        self.add_obj(branch, collected)
    self.stdout.write("Dumping %s records to %s" % (len(collected), output_filename))
    with open(output_filename, "w") as f:
        output = serializers.serialize("json", collected, indent=indent)
        f.write(output)