(cls, domain, app_id, identifier, force_rebuild=False,
            only_process_current_builds=False, task=None)
return current_schema
Builds a schema from Application builds for a given identifier

        :param domain: The domain that the export belongs to
        :param app_id: The app_id that the export belongs to (or None if export is not associated with an app.
        :param identifier: The unique identifier of the schema being exported.
            case_type for Case Exports and xmlns for Form Exports
        :param only_process_current_builds: Only process the current apps, not any builds. This
            means that deleted items may not be present in the schema since past builds have not been
            processed.
        :param task: A celery task to update the progress of the build
        :returns: Returns a ExportDataSchema instance
Builds a schema from Application builds for a given identifier
Builds a schema from Application builds for a given identifier
def generate_schema_from_builds(cls, domain, app_id, identifier, force_rebuild=False,
            only_process_current_builds=False, task=None):
        """Builds a schema from Application builds for a given identifier

        :param domain: The domain that the export belongs to
        :param app_id: The app_id that the export belongs to (or None if export is not associated with an app.
        :param identifier: The unique identifier of the schema being exported.
            case_type for Case Exports and xmlns for Form Exports
        :param only_process_current_builds: Only process the current apps, not any builds. This
            means that deleted items may not be present in the schema since past builds have not been
            processed.
        :param task: A celery task to update the progress of the build
        :returns: Returns a ExportDataSchema instance
        """

        original_id, original_rev = None, None
        apps_processed = 0
        current_schema = cls.get_latest_export_schema(domain, app_id, identifier)
        if (current_schema
                and not force_rebuild
                and current_schema.version == cls.schema_version()):
            original_id, original_rev = current_schema._id, current_schema._rev
        else:
            current_schema = cls()

        app_ids_for_domain = cls._get_current_app_ids_for_domain(domain, app_id)
        app_build_ids = []
        if not only_process_current_builds:
            app_build_ids = cls._get_app_build_ids_to_process(
                domain,
                app_ids_for_domain,
                current_schema.last_app_versions,
            )
        app_build_ids.extend(app_ids_for_domain)

        for app_doc in iter_docs(Application.get_db(), app_build_ids, chunksize=10):
            doc_type = app_doc.get('doc_type', '')
            if doc_type not in ('Application', 'LinkedApplication', 'Application-Deleted'):
                continue
            if (not app_doc.get('has_submissions', False) and
                    app_doc.get('copy_of')):
                continue

            app = Application.wrap(app_doc)
            try:
                current_schema = cls._process_app_build(
                    current_schema,
                    app,
                    identifier,
                )
            except Exception as e:
                logging.exception('Failed to process app {}. {}'.format(app._id, e))
                continue

            # Only record the version of builds on the schema. We don't care about
            # whether or not the schema has seen the current build because that always
            # gets processed.
            if app.copy_of:
                current_schema.record_update(app.copy_of, app.version)

            apps_processed += 1
            set_task_progress(task, apps_processed, len(app_build_ids))

        inferred_schema = cls._get_inferred_schema(domain, app_id, identifier)
        if inferred_schema:
            current_schema = cls._merge_schemas(current_schema, inferred_schema)

        try:
            current_schema = cls._reorder_schema_from_app(current_schema, app_id, identifier)
        except Exception as e:
            logging.exception('Failed to process app during reorder {}. {}'.format(app_id, e))

        current_schema.domain = domain
        current_schema.app_id = app_id
        current_schema.version = cls.schema_version()
        current_schema._set_identifier(identifier)

        current_schema = cls._save_export_schema(
            current_schema,
            original_id,
            original_rev
        )
        return current_schema
def generate_schema_from_builds ( cls , domain , app_id , identifier , force_rebuild = False , only_process_current_builds = False , task = None ) : original_id , original_rev = None , None apps_processed = 0 current_schema = cls . get_latest_export_schema ( domain , app_id , identifier ) if ( current_schema and not force_rebuild and current_schema . version == cls . schema_version ( ) ) : original_id , original_rev = current_schema . _id , current_schema . _rev else : current_schema = cls ( ) app_ids_for_domain = cls . _get_current_app_ids_for_domain ( domain , app_id ) app_build_ids = [ ] if not only_process_current_builds : app_build_ids = cls . _get_app_build_ids_to_process ( domain , app_ids_for_domain , current_schema . last_app_versions , ) app_build_ids . extend ( app_ids_for_domain ) for app_doc in iter_docs ( Application . get_db ( ) , app_build_ids , chunksize = 10 ) : doc_type = app_doc . get ( 'doc_type' , '' ) if doc_type not in ( 'Application' , 'LinkedApplication' , 'Application-Deleted' ) : continue if ( not app_doc . get ( 'has_submissions' , False ) and app_doc . get ( 'copy_of' ) ) : continue app = Application . wrap ( app_doc ) try : current_schema = cls . _process_app_build ( current_schema , app , identifier , ) except Exception as e : logging . exception ( 'Failed to process app {}. {}' . format ( app . _id , e ) ) continue # Only record the version of builds on the schema. We don't care about # whether or not the schema has seen the current build because that always # gets processed. if app . copy_of : current_schema . record_update ( app . copy_of , app . version ) apps_processed += 1 set_task_progress ( task , apps_processed , len ( app_build_ids ) ) inferred_schema = cls . _get_inferred_schema ( domain , app_id , identifier ) if inferred_schema : current_schema = cls . _merge_schemas ( current_schema , inferred_schema ) try : current_schema = cls . _reorder_schema_from_app ( current_schema , app_id , identifier ) except Exception as e : logging . exception ( 'Failed to process app during reorder {}. {}' . format ( app_id , e ) ) current_schema . domain = domain current_schema . app_id = app_id current_schema . version = cls . schema_version ( ) current_schema . _set_identifier ( identifier ) current_schema = cls . _save_export_schema ( current_schema , original_id , original_rev ) return current_schema