@@ -0,0 +1,1138 @@
+# -*- coding: utf-8 -*-%0Afrom django.core.management.base import BaseCommand%0Afrom osf.models import Registration, MetaSchema%0A%0APREREG_SCHEMA_NAMES = %5B%0A    'Prereg Challenge',%0A    'AsPredicted Preregistration',%0A    'OSF-Standard Pre-Data Collection Registration',%0A    'Replication Recipe (Brandt et al., 2013): Pre-Registration',%0A    %22Pre-Registration in Social Psychology (van 't Veer & Giner-Sorolla, 2016): Pre-Registration%22,%0A    'Election Research Preacceptance Competition',%0A%5D%0A%0Aclass Command(BaseCommand):%0A    %22%22%22Get a count of preregistrations, grouped by schema.%22%22%22%0A%0A    def handle(self, *args, **options):%0A        total = 0%0A        for schema_name in PREREG_SCHEMA_NAMES:%0A            metaschemas = MetaSchema.objects.filter(name=schema_name).only('id', 'schema_version')%0A            for metaschema in metaschemas:%0A                registrations = Registration.objects.filter(registered_schema=metaschema).get_roots()%0A                count = registrations.count()%0A                print('%7B%7D (Version %7B%7D): %7B%7D'.format(schema_name, metaschema.schema_version, count))%0A                total += count%0A        print('Total: %7B%7D'.format(total))%0A

Add command to get number of preregistrations by schema