Skip to content

Commit

Permalink
Merge pull request #1208 from cityofaustin/jc-compnent-event-audit-field
Browse files Browse the repository at this point in the history
Exclude audit fields from proj component event
  • Loading branch information
johnclary authored Nov 15, 2023
2 parents d790dee + 6ee7025 commit 7fbb167
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
15 changes: 14 additions & 1 deletion moped-database/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,20 @@
insert:
columns: '*'
update:
columns: '*'
columns:
- interim_project_component_id
- project_component_id
- location_description
- component_id
- is_deleted
- phase_id
- completion_date
- project_id
- created_at
- subphase_id
- created_by_user_id
- description
- srts_id
retry_conf:
interval_sec: 10
num_retries: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import RoomOutlinedIcon from "@mui/icons-material/RoomOutlined";
import { ProjectActivityLogTableMaps } from "../../views/projects/projectView/ProjectActivityLogTableMaps";

/** Fields which do not need to be rendered in the activity log */
const CHANGE_FIELDS_TO_IGNORE = [
"updated_by_user_id",
"created_by_user_id",
"created_at",
"updated_at",
];

export const formatComponentsActivity = (
change,
componentList,
Expand Down Expand Up @@ -113,10 +121,18 @@ export const formatComponentsActivity = (
// loop through fields to check for differences, push label onto changes Array
Object.keys(newRecord).forEach((field) => {
if (newRecord[field] !== oldRecord[field]) {
if (CHANGE_FIELDS_TO_IGNORE.includes(field)) {
return;
}
changes.push(entryMap.fields[field]?.label);
}
});

// handle an edge case where only ignored fields were edited
if (changes.length === 0) {
return { changeIcon: null, changeText: null };
}

return {
changeIcon,
changeText: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ const ProjectActivityLog = () => {
lookupData,
projectId
);
// allows log formatters to return a `null` changeText, causing the
// event to not be rendered at all
if (!changeText) {
return null;
}
return (
<TableRow key={change.activity_id}>
<TableCell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,19 @@ export const ProjectActivityLogTableMaps = {
srts_id: {
label: "Safe Routes to School infrastructure plan record identifier",
},
// we don't render these audit fields in the activity log UI
created_at: {
label: "creation date"
},
created_by_user_id: {
label: "created by user"
},
updated_at: {
label: "update date"
},
updated_by_user_id: {
label: "updated by user"
}
},
},
moped_project_files: {
Expand Down

0 comments on commit 7fbb167

Please sign in to comment.