function dedupeAuditLogs()

in app/services/PlutoCore.ts [3:23]


function dedupeAuditLogs(
  entries: PlutoAuditLog[],
  limit: number
): PlutoAuditLog[] {
  /*
    I really don't find this pleasant or pretty, but I could not think of a nicer way to get this de-duplicate done
    efficiently
     */
  let deDuped: PlutoAuditLog[] = [];
  let countedIds: string[] = [];

  for (let i = 0; i < entries.length; ++i) {
    const elem = entries[i];
    if (!countedIds.includes(elem.targetObjectId)) {
      deDuped = deDuped.concat(elem);
      countedIds = countedIds.concat(elem.targetObjectId);
    }
    if (deDuped.length >= limit) break;
  }
  return deDuped;
}