Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion enums/enum-functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InformationSourceType, LabelSource, SearchGroup, Slice, StaticOrderByKeys } from "./enums";
import { InformationSourceType, IntegrationType, LabelSource, SearchGroup, Slice, StaticOrderByKeys } from "./enums";

export function informationSourceTypeToString(source: InformationSourceType, short: boolean, forDisplay: boolean = true) {
if (forDisplay) {
Expand Down Expand Up @@ -58,4 +58,10 @@ export function getOrderByDisplayName(orderByKey: string) {
case StaticOrderByKeys.WEAK_SUPERVISION_CONFIDENCE: return "Weak Supervision Confidence";
default: return orderByKey; //attributes
}
}

export const INTEGRATIONS_DISPLAY = {
[IntegrationType.GITHUB_FILE]: "GitHub File",
[IntegrationType.GITHUB_ISSUE]: "GitHub Issue",
[IntegrationType.SHAREPOINT]: "SharePoint",
}
6 changes: 6 additions & 0 deletions enums/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ export enum ModelsDownloadedStatus {
DOWNLOADING = 'downloading',
INITIALIZING = 'initializing',
FAILED = 'failed',
}

export enum IntegrationType {
GITHUB_ISSUE = 'GITHUB_ISSUE',
GITHUB_FILE = 'GITHUB_FILE',
SHAREPOINT = 'SHAREPOINT',
}
48 changes: 48 additions & 0 deletions post-process-functions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { jsonCopy } from "./general";

export function postProcessRecord(record: any, attributes: any[]) {
const prepareRecord = jsonCopy(record);
if (!prepareRecord.hasOwnProperty('data')) {
if (prepareRecord.hasOwnProperty('fullRecordData')) {
prepareRecord.data = prepareRecord.fullRecordData;
}
else if (prepareRecord.hasOwnProperty('recordData')) {
prepareRecord.data = prepareRecord.recordData;
} else {
throw new Error("Cant find record data in record object");
}
}
attributes.forEach((attribute, index) => {
if (typeof prepareRecord.data[attribute.name] === 'boolean') {
prepareRecord.data[attribute.name] = prepareRecord.data[attribute.name].toString();
}
});
return prepareRecord;
}

export function postProcessAttributes(attributes: any[]) {
const prepareAttributes = jsonCopy(attributes);
if (attributes && attributes.length > 0) {
if (!attributes[0].hasOwnProperty('key')) {
prepareAttributes.forEach((attribute, index) => {
if (attribute.id !== null) {
attribute.key = attribute.id;
} else {
throw new Error("Cant find attribute id in attribute object");
}
});
}
}
return prepareAttributes;
}

export function postProcessUpdateAndSortRecords(prev: any[], newRecords: any[]) {
const merged = [...prev, ...newRecords];
const uniqueRecords = Array.from(
new Map(merged.map((item) => [item.data?.running_id, item])).values()
);
uniqueRecords.sort(
(a, b) => (a.data?.running_id || 0) - (b.data?.running_id || 0)
);
return uniqueRecords;
}