rows = @import.rows.to_a valid_rows_count = rows.count(&:valid?) invalid_rows_count = rows.length - valid_rows_count cleaned = @import.cleaned_from_validation_stats?(invalid_rows_count: invalid_rows_count) publishable = @import.publishable_from_validation_stats?(invalid_rows_count: invalid_rows_count) mapping_counts = @import.mapping_status_counts json.data do json.id @import.id json.type @import.type json.status @import.status json.created_at @import.created_at json.updated_at @import.updated_at json.account_id @import.account_id json.error @import.error if @import.error.present? json.status_detail do json.partial! "status_detail", import: @import, include_validation_stats: true, valid_rows_count: valid_rows_count, invalid_rows_count: invalid_rows_count, cleaned: cleaned, publishable: publishable end json.configuration do json.date_col_label @import.date_col_label json.amount_col_label @import.amount_col_label json.name_col_label @import.name_col_label json.category_col_label @import.category_col_label json.tags_col_label @import.tags_col_label json.notes_col_label @import.notes_col_label json.account_col_label @import.account_col_label json.date_format @import.date_format json.number_format @import.number_format json.signage_convention @import.signage_convention end json.stats do json.rows_count @import.rows_count json.valid_rows_count valid_rows_count json.invalid_rows_count invalid_rows_count json.mappings_count mapping_counts[:mappings_count] json.unassigned_mappings_count mapping_counts[:unassigned_mappings_count] end # Only show a subset of rows for preview if needed, or link to a separate rows endpoint # json.sample_rows @import.rows.limit(5) end