<s> def get_latest_case_export_schema ( domain , case_type ) : <EOL> from . models import CaseExportDataSchema <EOL> key = [ domain , '<STR_LIT>' , case_type ] <EOL> return _get_latest_export_schema ( CaseExportDataSchema , key ) <EOL> def get_latest_form_export_schema ( domain , app_id , xmlns ) : <EOL> from . models import FormExportDataSchema <EOL> key = [ domain , '<STR_LIT>' , app_id , xmlns ] <EOL> return _get_latest_export_schema ( FormExportDataSchema , key ) <EOL> def _get_latest_export_schema ( cls , key ) : <EOL> result = cls . get_db ( ) . view ( <EOL> '<STR_LIT>' , <EOL> startkey = key + [ { } ] , <EOL> endkey = key , <EOL> include_docs = True , <EOL> limit = <NUM_LIT:1> , <EOL> reduce = False , <EOL> descending = True , <EOL> ) . first ( ) <EOL> return cls . wrap ( result [ '<STR_LIT>' ] ) if result else None <EOL> def get_form_export_instances ( domain ) : <EOL> from . models import FormExportInstance <EOL> key = [ domain , '<STR_LIT>' ] <EOL> return _get_export_instance ( FormExportInstance , key ) <EOL> def get_case_export_instances ( domain ) : <EOL> from . models import CaseExportInstance <EOL> key = [ domain , '<STR_LIT>' ] <EOL> return _get_export_instance ( CaseExportInstance , key ) <EOL> def _get_export_instance ( cls , key ) : <EOL> results = cls . get_db ( ) . view ( <EOL> '<STR_LIT>' , <EOL> startkey = key , <EOL> endkey = key + [ { } ] , <EOL> include_docs = True , <EOL> reduce = False , <EOL> ) . all ( ) <EOL> return [ cls . wrap ( result [ '<STR_LIT>' ] ) for result in results ] <EOL> def get_all_daily_saved_export_instances ( ) : <EOL> from . models import ExportInstance <EOL> results = ExportInstance . get_db ( ) . view ( <EOL> "<STR_LIT>" , <EOL> startkey = [ True ] , <EOL> endkey = [ True , { } ] , <EOL> include_docs = True , <EOL> reduce = False , <EOL> ) . all ( ) <EOL> return [ _properly_wrap_export_instance ( result [ '<STR_LIT>' ] ) for result in results ] <EOL> def get_properly_wrapped_export_instance ( doc_id ) : <EOL> from . models import ExportInstance <EOL> doc = ExportInstance . get_db ( ) . get ( doc_id ) <EOL> return _properly_wrap_export_instance ( doc ) <EOL> def _properly_wrap_export_instance ( doc ) : <EOL> from . models import FormExportInstance <EOL> from . models import CaseExportInstance <EOL> from . models import ExportInstance <EOL> class_ = { <EOL> "<STR_LIT>" : FormExportInstance , <EOL> "<STR_LIT>" : CaseExportInstance , <EOL> } . get ( doc [ '<STR_LIT>' ] , ExportInstance ) <EOL> return class_ . wrap ( doc ) </s>
