def get_csv(request): """ Download a csv of the results. """ import_file_id = request.GET.get('import_file_id') cleansing_results = get_cache_raw(Cleansing.cache_key(import_file_id)) response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="Data Cleansing Results.csv"' writer = csv.writer(response) writer.writerow(['Address Line 1', 'PM Property ID', 'Tax Lot ID', 'Custom ID', 'Field', 'Error Message', 'Severity']) for row in cleansing_results: for result in row['cleansing_results']: field = result['field'] if field in Cleansing.ASSESSOR_FIELDS_BY_COLUMN: field = Cleansing.ASSESSOR_FIELDS_BY_COLUMN[field]['title'] writer.writerow([ row['address_line_1'], row['pm_property_id'], row['tax_lot_id'], row['custom_id_1'], field, result['message'], result['severity'] ]) return response
def get_csv(request): """ Download a csv of the results. """ import_file_id = request.GET.get('import_file_id') cleansing_results = get_cache_raw(Cleansing.cache_key(import_file_id)) response = HttpResponse(content_type='text/csv') response[ 'Content-Disposition'] = 'attachment; filename="Data Cleansing Results.csv"' writer = csv.writer(response) writer.writerow([ 'Address Line 1', 'PM Property ID', 'Tax Lot ID', 'Custom ID', 'Field', 'Error Message', 'Severity' ]) for row in cleansing_results: for result in row['cleansing_results']: field = result['field'] if field in Cleansing.ASSESSOR_FIELDS_BY_COLUMN: field = Cleansing.ASSESSOR_FIELDS_BY_COLUMN[field]['title'] writer.writerow([ row['address_line_1'], row['pm_property_id'], row['tax_lot_id'], row['custom_id_1'], field, result['message'], result['severity'] ]) return response
def get_cleansing_results(self, request, pk=None): """ Retrieve the details of the cleansing script. --- type: status: required: true type: string description: either success or error message: type: string description: additional information, if any progress: type: integer description: integer percent of completion data: type: JSON description: object describing the results of the cleansing parameter_strategy: replace parameters: - name: pk description: Import file ID required: true paramType: path """ import_file_id = pk cleansing_results = get_cache_raw(Cleansing.cache_key(import_file_id)) return JsonResponse({ 'status': 'success', 'message': 'Cleansing complete', 'progress': 100, 'data': cleansing_results })
def get_csv(request): """ Download a csv of the results. """ import_file_id = request.GET.get("import_file_id") cleansing_results = get_cache_raw(Cleansing.cache_key(import_file_id)) response = HttpResponse(content_type="text/csv") response["Content-Disposition"] = 'attachment; filename="Data Cleansing Results.csv"' writer = csv.writer(response) writer.writerow( ["Address Line 1", "PM Property ID", "Tax Lot ID", "Custom ID", "Field", "Error Message", "Severity"] ) for row in cleansing_results: for result in row["cleansing_results"]: writer.writerow( [ row["address_line_1"], row["pm_property_id"], row["tax_lot_id"], row["custom_id_1"], result["formatted_field"], result["detailed_message"], result["severity"], ] ) return response
def get_cleansing_results(request): """ Retrieve the details of the cleansing script. """ import_file_id = request.GET.get("import_file_id") cleansing_results = get_cache_raw(Cleansing.cache_key(import_file_id)) return {"status": "success", "message": "Cleansing complete", "progress": 100, "data": cleansing_results}
def get_cleansing_results(request): """ Retrieve the details of the cleansing script. """ import_file_id = request.GET.get('import_file_id') cleansing_results = cache.get(Cleansing.cache_key(import_file_id), []) for i, row in enumerate(cleansing_results): for j, result in enumerate(row['cleansing_results']): if result['field'] in Cleansing.ASSESSOR_FIELDS_BY_COLUMN: result['field'] = Cleansing.ASSESSOR_FIELDS_BY_COLUMN[result['field']]['title'] return cleansing_results
def get_cleansing_results(request): """ Retrieve the details of the cleansing script. """ import_file_id = request.GET.get('import_file_id') cleansing_results = get_cache_raw(Cleansing.cache_key(import_file_id)) return { 'status': 'success', 'message': 'Cleansing complete', 'progress': 100, 'data': cleansing_results }
def get_cleansing_results(request): """ Retrieve the details of the cleansing script. """ import_file_id = request.GET.get('import_file_id') cleansing_results = get_cache_raw(Cleansing.cache_key(import_file_id)) # add in additional fields for view for i, row in enumerate(cleansing_results): for j, result in enumerate(row['cleansing_results']): if result['field'] in Cleansing.ASSESSOR_FIELDS_BY_COLUMN: result['field'] = Cleansing.ASSESSOR_FIELDS_BY_COLUMN[result['field']]['title'] return { 'status': 'success', 'message': 'Cleansing complete', 'progress': 100, 'data': cleansing_results }
def get_csv(self, request, pk=None): """ Download a csv of the results. --- type: status: required: true type: string description: either success or error progress_key: type: integer description: ID of background job, for retrieving job progress parameter_strategy: replace parameters: - name: pk description: Import file ID required: true paramType: path """ import_file_id = pk cleansing_results = get_cache_raw(Cleansing.cache_key(import_file_id)) response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="Data Cleansing Results.csv"' writer = csv.writer(response) writer.writerow(['Address Line 1', 'PM Property ID', 'Tax Lot ID', 'Custom ID', 'Field', 'Error Message', 'Severity']) for row in cleansing_results: for result in row['cleansing_results']: writer.writerow([ row['address_line_1'], row['pm_property_id'], row['tax_lot_id'], row['custom_id_1'], result['formatted_field'], result['detailed_message'], result['severity'] ]) return response
def get_cleansing_results(request): """ Retrieve the details of the cleansing script. """ import_file_id = request.GET.get('import_file_id') cleansing_results = get_cache_raw(Cleansing.cache_key(import_file_id)) # add in additional fields for view for i, row in enumerate(cleansing_results): for j, result in enumerate(row['cleansing_results']): if result['field'] in Cleansing.ASSESSOR_FIELDS_BY_COLUMN: result['field'] = Cleansing.ASSESSOR_FIELDS_BY_COLUMN[ result['field']]['title'] return { 'status': 'success', 'message': 'Cleansing complete', 'progress': 100, 'data': cleansing_results }