Skip to content

Commit

Permalink
Improve path and cleanup status check
Browse files Browse the repository at this point in the history
  • Loading branch information
aheber committed Mar 17, 2024
1 parent 374fa75 commit ad1b474
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 270 deletions.
89 changes: 4 additions & 85 deletions dlrs/main/classes/LookupRollupStatusCheckController.cls
Original file line number Diff line number Diff line change
@@ -1,45 +1,4 @@
public with sharing class LookupRollupStatusCheckController {
// Global variables
public static LookupRollupSummary2__mdt LookupRollupSummary;
public static List<RollupSummary> rollups;
public static Map<id, RollupSummary> mapRollups;

/**
* Check if the rollup has any error logs
*/
@AuraEnabled(Cacheable=true)
public static Integer getAssociatedErrorLogs(String lookupID) {
return [
SELECT COUNT()
FROM LookupRollupSummaryLog__c
WHERE ParentId__c = :lookupID
];
}

/**
* Check if the rollup has a failed calculate rollup jobs
*/
@AuraEnabled(Cacheable=true)
public static Integer getCalculateJobs(String lookupID) {
return [
SELECT COUNT()
FROM LookupRollupCalculateJob__c
WHERE LookupRollupSummaryId__c = :lookupID
];
}

/**
* Check if the rollup has any schedule items
*/
@AuraEnabled(Cacheable=true)
public static Integer getSpecificScheduledItems(String lookupID) {
return [
SELECT COUNT()
FROM LookupRollupSummaryScheduleItems__c
WHERE LookupRollupSummary2__c = :lookupID
];
}

/**
* Get count of scheduled items older than yesterday
* The assumption is that normal processing should have handled these
Expand All @@ -56,10 +15,10 @@ public with sharing class LookupRollupStatusCheckController {
/**
* Check if the rollup has a Full Calculate schedule
*/
@AuraEnabled(Cacheable=true)
@AuraEnabled
public static Datetime getScheduledFullCalculates(String lookupID) {
try {
LookupRollupSummary = (LookupRollupSummary2__mdt) new RollupSummariesSelector.CustomMetadataSelector(
LookupRollupSummary2__mdt LookupRollupSummary = (LookupRollupSummary2__mdt) new RollupSummariesSelector.CustomMetadataSelector(
false,
true
)
Expand All @@ -86,7 +45,7 @@ public with sharing class LookupRollupStatusCheckController {
@AuraEnabled
public static Boolean hasChildTriggerDeployed(String lookupID) {
try {
LookupRollupSummary = (LookupRollupSummary2__mdt) new RollupSummariesSelector.CustomMetadataSelector(
LookupRollupSummary2__mdt LookupRollupSummary = (LookupRollupSummary2__mdt) new RollupSummariesSelector.CustomMetadataSelector(
false,
true
)
Expand All @@ -108,50 +67,10 @@ public with sharing class LookupRollupStatusCheckController {
return false;
}

@AuraEnabled(Cacheable=true)
public static Boolean hasParentTriggerDeployed(String lookupID) {
try {
LookupRollupSummary = (LookupRollupSummary2__mdt) new RollupSummariesSelector.CustomMetadataSelector(
false,
true
)
.selectById(new Set<String>{ lookupID })[0]
.Record;

if (LookupRollupSummary != null) {
RollupSummary rs = new RollupSummary(LookupRollupSummary);
String parentTrigger = RollupSummaries.makeParentTriggerName(rs);
ApexTriggersSelector selector = new ApexTriggersSelector();
Map<String, ApexTrigger> loadTriggers = selector.selectByName(
new Set<String>{ ParentTrigger }
);

if (loadTriggers.size() > 0) {
return true;
}
}
} catch (Exception e) {
}
return false;
}

/*
* Rollup - General Status Information
*
*/

/**
* Check if there are any schedule items in the system
*/
@AuraEnabled(Cacheable=true)
public static Integer getAllScheduledItems() {
return [SELECT COUNT() FROM LookupRollupSummaryScheduleItems__c];
}

/**
* Check if cron job is running for DLRS
*/
@AuraEnabled(Cacheable=true)
@AuraEnabled
public static Integer getScheduledJobs() {
return new AsyncApexJobsSelector()
.getScheduledInstancesOfType(RollupJob.class)
Expand Down
6 changes: 6 additions & 0 deletions dlrs/main/lwc/flexiblePath/flexiblePath.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
href="#"
role="option"
tabindex="-1"
data-step={step.name}
onclick={handlePathStepClick}
>
<span class="slds-path__stage">
<lightning-icon
Expand All @@ -51,6 +53,8 @@
href="#"
role="option"
tabindex="-1"
data-step={step.name}
onclick={handlePathStepClick}
>
<span class="slds-path__stage">
<lightning-icon
Expand All @@ -74,6 +78,8 @@
href="#"
role="option"
tabindex="-1"
data-step={step.name}
onclick={handlePathStepClick}
>
<span class="slds-path__stage">
<lightning-icon
Expand Down
16 changes: 16 additions & 0 deletions dlrs/main/lwc/flexiblePath/flexiblePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ export default class FlexiblePath extends LightningElement {
);
}

handlePathStepClick(event) {
const step = this.steps.find(
(s) => s.name === event.currentTarget.dataset.step
);
if (step) {
this.dispatchEvent(
new CustomEvent("nextactionclick", {
detail: {
label: step.label,
name: step.name
}
})
);
}
}

handleNextActionClick() {
const nextAction = this.nextAction;
this.dispatchEvent(
Expand Down
1 change: 1 addition & 0 deletions dlrs/main/lwc/manageRollups/manageRollups.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
onsort={handleOnSort}
>
</lightning-datatable>
<lightning-spinner lwc:if={isLoading}></lightning-spinner>
</div>
</lightning-card>
</lightning-layout-item>
Expand Down
3 changes: 3 additions & 0 deletions dlrs/main/lwc/manageRollups/manageRollups.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
rollups = {};
rollupList = [];
searchFilter = "";
isLoading = true;
selectedRollup = undefined;

connectedCallback() {
Expand All @@ -111,6 +112,7 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
}

async refreshRollups() {
this.isLoading = true;
this.rollups = await getAllRollupConfigs();

Object.keys(this.rollups).forEach((k) => {
Expand All @@ -127,6 +129,7 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
this.openEditor(null);
}
this.calcRollupList();
this.isLoading = false;
}

calcRollupList() {
Expand Down
22 changes: 17 additions & 5 deletions dlrs/main/lwc/rollupEditor/rollupEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,23 @@
errors={errors.Description__c}
></c-rollup-editor-error>
</lightning-layout-item>
<lightning-layout-item size="12">
<c-rollup-status-check
name={rollup.Id}
lwc:if={rollup.Id}
></c-rollup-status-check>
<lightning-layout-item
size="12"
large-device-size="6"
lwc:if={rollup.Id}
>
Outstanding Scheduled Items
<lightning-badge
label={outstandingScheduledItems.data}
></lightning-badge>
</lightning-layout-item>
<lightning-layout-item
size="12"
large-device-size="6"
lwc:if={rollup.Id}
>
Next Full Calculate
<lightning-badge label={nextFullCalculateAt}></lightning-badge>
</lightning-layout-item>
</lightning-layout>
</lightning-accordion-section>
Expand Down
27 changes: 26 additions & 1 deletion dlrs/main/lwc/rollupEditor/rollupEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import getManageTriggerPageUrl from "@salesforce/apex/RollupEditorController.get
import getFullCalculatePageUrl from "@salesforce/apex/RollupEditorController.getFullCalculatePageUrl";
import getScheduleCalculatePageUrl from "@salesforce/apex/RollupEditorController.getScheduleCalculatePageUrl";
import hasChildTriggerDeployed from "@salesforce/apex/LookupRollupStatusCheckController.hasChildTriggerDeployed";
import getScheduledFullCalculates from "@salesforce/apex/LookupRollupStatusCheckController.getScheduledFullCalculates";
import getScheduledJobs from "@salesforce/apex/LookupRollupStatusCheckController.getScheduledJobs";
import getOutstandingScheduledItemsForLookup from "@salesforce/apex/LookupRollupStatusCheckController.getOutstandingScheduledItemsForLookup";
import ClassSchedulerModal from "c/classSchedulerModal";
Expand Down Expand Up @@ -59,6 +60,7 @@ export default class RollupEditor extends LightningModal {
isLoading = false;
childTriggerIsDeployed = false;
rollupId;
nextFullCalculateAt = "";

@wire(getOutstandingScheduledItemsForLookup, { lookupID: "$rollupId" })
outstandingScheduledItems;
Expand Down Expand Up @@ -147,6 +149,10 @@ export default class RollupEditor extends LightningModal {
rollupName: this.rollupName
});
this.rollupId = this.rollup.Id;
this.nextFullCalculateAt =
(await getScheduledFullCalculates({
lookupId: this.rollupId
})) ?? "Not Scheduled";
} catch (error) {
this.errors.record = [error.message];
}
Expand Down Expand Up @@ -263,7 +269,26 @@ export default class RollupEditor extends LightningModal {
label: "Schedule Rollup Job",
description: "Scheduled RollupJob to process Scheduled Items",
className: "RollupJob",
size: "small"
size: "small",
templates: [
{
label: "Once Every Day",
value: "daily",
selectors: ["single-hour"],
presets: { hours: ["3"] }
},
{
label: "Once Every Hour",
value: "hourly",
selectors: ["single-minute"]
},
{
label: "Every 15 minutes",
value: "every15",
selectors: [],
presets: { minutes: ["0", "15", "30", "45"] }
}
]
});
// recalculate Path after Schedule is created
this.configureSteps();
Expand Down
27 changes: 0 additions & 27 deletions dlrs/main/lwc/rollupStatusCheck/rollupStatusCheck.html

This file was deleted.

Loading

0 comments on commit ad1b474

Please sign in to comment.