Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e0d575454e | |||
| 32bba31e72 | |||
| 1233535b20 | |||
| 2c737b22f1 | |||
| a3bfe9f374 | |||
| a106bb15a8 |
@@ -318,9 +318,9 @@ jobs:
|
|||||||
TAG=${{ github.event.release.tag_name }}
|
TAG=${{ github.event.release.tag_name }}
|
||||||
JOB="job/dalpuri-sync-${TAG}"
|
JOB="job/dalpuri-sync-${TAG}"
|
||||||
|
|
||||||
kubectl wait --for=condition=complete --timeout=1800s -n optima "$JOB" &
|
kubectl wait --for=condition=complete --timeout=7200s -n optima "$JOB" &
|
||||||
WAIT_COMPLETE=$!
|
WAIT_COMPLETE=$!
|
||||||
kubectl wait --for=condition=failed --timeout=1800s -n optima "$JOB" &
|
kubectl wait --for=condition=failed --timeout=7200s -n optima "$JOB" &
|
||||||
WAIT_FAILED=$!
|
WAIT_FAILED=$!
|
||||||
|
|
||||||
wait -n $WAIT_COMPLETE $WAIT_FAILED
|
wait -n $WAIT_COMPLETE $WAIT_FAILED
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
backoffLimit: 0
|
backoffLimit: 0
|
||||||
ttlSecondsAfterFinished: 86400
|
ttlSecondsAfterFinished: 86400
|
||||||
activeDeadlineSeconds: 1800
|
activeDeadlineSeconds: 7200
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
@@ -17,10 +17,12 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: sync
|
- name: sync
|
||||||
image: ghcr.io/horizonstacksoftware/optima-dalpuri-sync:RELEASE_TAG
|
image: ghcr.io/horizonstacksoftware/optima-dalpuri-sync:RELEASE_TAG
|
||||||
envFrom:
|
|
||||||
- secretRef:
|
|
||||||
name: api-env-secret
|
|
||||||
env:
|
env:
|
||||||
|
- name: CW_DATABASE_URL
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: api-env-secret
|
||||||
|
key: CW_DATABASE_URL
|
||||||
- name: API_DATABASE_URL
|
- name: API_DATABASE_URL
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
|
|||||||
@@ -294,6 +294,22 @@ const refreshContextFromApi = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cwMembers = await apiPrisma.cwMember.findMany({
|
||||||
|
select: { cwMemberId: true, identifier: true },
|
||||||
|
});
|
||||||
|
for (const member of cwMembers) {
|
||||||
|
if (
|
||||||
|
member.cwMemberId != null &&
|
||||||
|
member.identifier &&
|
||||||
|
!context.userIdentifiersByMemberRecId.has(member.cwMemberId)
|
||||||
|
) {
|
||||||
|
context.userIdentifiersByMemberRecId.set(
|
||||||
|
member.cwMemberId,
|
||||||
|
member.identifier
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const board of boards) {
|
for (const board of boards) {
|
||||||
context.serviceTicketBoardUidsById.set(board.id, board.uid);
|
context.serviceTicketBoardUidsById.set(board.id, board.uid);
|
||||||
}
|
}
|
||||||
@@ -426,6 +442,12 @@ const sanitizeModelData = (
|
|||||||
) {
|
) {
|
||||||
sanitized.statusId = null;
|
sanitized.statusId = null;
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
sanitized.locationId != null &&
|
||||||
|
!context.corporateLocationIds.has(sanitized.locationId as number)
|
||||||
|
) {
|
||||||
|
sanitized.locationId = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetModel === "schedule") {
|
if (targetModel === "schedule") {
|
||||||
@@ -734,6 +756,11 @@ const getConfigForTable = (table: string): SyncTableConfig | null => {
|
|||||||
secondarySalesFlag: true,
|
secondarySalesFlag: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
soOppStatus: {
|
||||||
|
select: {
|
||||||
|
closedFlag: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+42
-10
@@ -323,6 +323,22 @@ const refreshContextFromApi = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cwMembers = await apiPrisma.cwMember.findMany({
|
||||||
|
select: { cwMemberId: true, identifier: true },
|
||||||
|
});
|
||||||
|
for (const member of cwMembers) {
|
||||||
|
if (
|
||||||
|
member.cwMemberId != null &&
|
||||||
|
member.identifier &&
|
||||||
|
!context.userIdentifiersByMemberRecId.has(member.cwMemberId)
|
||||||
|
) {
|
||||||
|
context.userIdentifiersByMemberRecId.set(
|
||||||
|
member.cwMemberId,
|
||||||
|
member.identifier
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const board of boards) {
|
for (const board of boards) {
|
||||||
context.serviceTicketBoardUidsById.set(board.id, board.uid);
|
context.serviceTicketBoardUidsById.set(board.id, board.uid);
|
||||||
}
|
}
|
||||||
@@ -636,6 +652,13 @@ const sanitizeModelData = (
|
|||||||
) {
|
) {
|
||||||
sanitized.stageId = null;
|
sanitized.stageId = null;
|
||||||
}
|
}
|
||||||
|
// Nullify locationId if the corporate location doesn't exist
|
||||||
|
if (
|
||||||
|
sanitized.locationId != null &&
|
||||||
|
!context.corporateLocationIds.has(sanitized.locationId as number)
|
||||||
|
) {
|
||||||
|
sanitized.locationId = null;
|
||||||
|
}
|
||||||
// Nullify taxCodeId if the tax code hasn't synced yet
|
// Nullify taxCodeId if the tax code hasn't synced yet
|
||||||
if (
|
if (
|
||||||
sanitized.taxCodeId != null &&
|
sanitized.taxCodeId != null &&
|
||||||
@@ -1328,6 +1351,15 @@ export const executeFullDalpuriSync = async (options?: {
|
|||||||
const isTimedOut = () => Date.now() - syncStartTime > timeoutMs;
|
const isTimedOut = () => Date.now() - syncStartTime > timeoutMs;
|
||||||
|
|
||||||
const steps: Step[] = [
|
const steps: Step[] = [
|
||||||
|
{
|
||||||
|
name: "CW Members",
|
||||||
|
sourceModel: "member",
|
||||||
|
targetModel: "cwMember",
|
||||||
|
translation: cwMemberTranslation as unknown as AnyTranslation,
|
||||||
|
uniqueField: "cwMemberId",
|
||||||
|
sourceIdField: "memberRecId",
|
||||||
|
sourceUpdatedField: "lastUpdatedUtc",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Users",
|
name: "Users",
|
||||||
sourceModel: "member",
|
sourceModel: "member",
|
||||||
@@ -1342,15 +1374,6 @@ export const executeFullDalpuriSync = async (options?: {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "CW Members",
|
|
||||||
sourceModel: "member",
|
|
||||||
targetModel: "cwMember",
|
|
||||||
translation: cwMemberTranslation as unknown as AnyTranslation,
|
|
||||||
uniqueField: "cwMemberId",
|
|
||||||
sourceIdField: "memberRecId",
|
|
||||||
sourceUpdatedField: "lastUpdatedUtc",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "Companies",
|
name: "Companies",
|
||||||
sourceModel: "company",
|
sourceModel: "company",
|
||||||
@@ -1585,6 +1608,11 @@ export const executeFullDalpuriSync = async (options?: {
|
|||||||
secondarySalesFlag: true,
|
secondarySalesFlag: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
soOppStatus: {
|
||||||
|
select: {
|
||||||
|
closedFlag: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1860,7 +1888,11 @@ export const executeForcedIncrementalDalpuriSync = async (options?: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (import.meta.main) {
|
if (import.meta.main) {
|
||||||
executeFullDalpuriSync().catch((error) => {
|
executeFullDalpuriSync()
|
||||||
|
.then(() => {
|
||||||
|
process.exit(0);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
console.error("CW -> API sync failed:", error);
|
console.error("CW -> API sync failed:", error);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
Opportunity as CwOpportunity,
|
Opportunity as CwOpportunity,
|
||||||
OpportunityMember as CwOpportunityMember,
|
OpportunityMember as CwOpportunityMember,
|
||||||
|
SoOppStatus as CwSoOppStatus,
|
||||||
} from "../../generated/prisma/client";
|
} from "../../generated/prisma/client";
|
||||||
import { OpportunityInterest } from "../../../api/generated/prisma/client";
|
import { OpportunityInterest } from "../../../api/generated/prisma/client";
|
||||||
import { Translation, skipRow } from "./types";
|
import { Translation, skipRow } from "./types";
|
||||||
@@ -30,6 +31,7 @@ type ApiOpportunityRecord = {
|
|||||||
dateBecameLead?: Date | null;
|
dateBecameLead?: Date | null;
|
||||||
closedDate?: Date | null;
|
closedDate?: Date | null;
|
||||||
closedFlag: boolean;
|
closedFlag: boolean;
|
||||||
|
locationId?: number | null;
|
||||||
closedById?: string | null;
|
closedById?: string | null;
|
||||||
updatedBy: string;
|
updatedBy: string;
|
||||||
eneteredBy: string;
|
eneteredBy: string;
|
||||||
@@ -42,6 +44,7 @@ type CwOpportunityWithMembers = CwOpportunity & {
|
|||||||
CwOpportunityMember,
|
CwOpportunityMember,
|
||||||
"memberRecId" | "primarySalesFlag" | "secondarySalesFlag"
|
"memberRecId" | "primarySalesFlag" | "secondarySalesFlag"
|
||||||
>[];
|
>[];
|
||||||
|
soOppStatus?: Pick<CwSoOppStatus, "closedFlag"> | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const toInterest = (value: number | null): OpportunityInterest | null => {
|
const toInterest = (value: number | null): OpportunityInterest | null => {
|
||||||
@@ -119,13 +122,19 @@ export const opportunityTranslation: Translation<
|
|||||||
},
|
},
|
||||||
{ from: "companyRecId", to: "companyId" },
|
{ from: "companyRecId", to: "companyId" },
|
||||||
{ from: "contactRecId", to: "contactId" },
|
{ from: "contactRecId", to: "contactId" },
|
||||||
|
{ from: "ownerLevelRecId", to: "locationId" },
|
||||||
{ from: "companyAddressRecId", to: "siteId" },
|
{ from: "companyAddressRecId", to: "siteId" },
|
||||||
{ from: "poNumber", to: "customerPO" },
|
{ from: "poNumber", to: "customerPO" },
|
||||||
{ from: "dateCloseExpected", to: "expectedCloseDate" },
|
{ from: "dateCloseExpected", to: "expectedCloseDate" },
|
||||||
{ from: "datePipelineChange", to: "pipelineChangeDate" },
|
{ from: "datePipelineChange", to: "pipelineChangeDate" },
|
||||||
{ from: "dateBecameLead", to: "dateBecameLead" },
|
{ from: "dateBecameLead", to: "dateBecameLead" },
|
||||||
{ from: "dateClosed", to: "closedDate" },
|
{ from: "dateClosed", to: "closedDate" },
|
||||||
{ from: "oldCloseFlag", to: "closedFlag" },
|
{
|
||||||
|
from: "oldCloseFlag",
|
||||||
|
to: "closedFlag",
|
||||||
|
process: (_value, _context, row) =>
|
||||||
|
row.soOppStatus?.closedFlag ?? row.oldCloseFlag ?? false,
|
||||||
|
},
|
||||||
{ from: "closedBy", to: "closedById" },
|
{ from: "closedBy", to: "closedById" },
|
||||||
{
|
{
|
||||||
from: "updatedBy",
|
from: "updatedBy",
|
||||||
|
|||||||
Reference in New Issue
Block a user