Skip to content
Open
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
86 changes: 0 additions & 86 deletions force-app/main/default/classes/GetChallengesTest.cls

This file was deleted.

5 changes: 0 additions & 5 deletions force-app/main/default/classes/GetChallengesTest.cls-meta.xml

This file was deleted.

12 changes: 6 additions & 6 deletions force-app/main/default/classes/actions/GetChallenges.cls
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public with sharing class GetChallenges {

public class Output {
@InvocableVariable(description='List of Challenge Objects found')
public List<Challenge__c> challenges;
public List<AmyDataKit__Challenge__c> challenges;
@InvocableVariable(description='Result message of the search')
public String message;

public Output(List<Challenge__c> challenges, String message) {
public Output(List<AmyDataKit__Challenge__c> challenges, String message) {
this.challenges = challenges;
this.message = message;
}
Expand All @@ -34,12 +34,12 @@ public with sharing class GetChallenges {
public static List<Output> getChallenges(List<Input> inputList) {
List<Output> results = new List<Output>();
if (inputList == null || inputList.isEmpty()) {
results.add(new Output(new List<Challenge__c>(), 'No input provided'));
results.add(new Output(new List<AmyDataKit__Challenge__c>(), 'No input provided'));
return results;
}

Input queryInput = inputList[0];
List<Challenge__c> challenges = ChallengeHelper.queryChallenges(
List<AmyDataKit__Challenge__c> challenges = ChallengeHelper.queryChallenges(
queryInput.status,
queryInput.startDate,
queryInput.endDate,
Expand All @@ -49,14 +49,14 @@ public with sharing class GetChallenges {
);

// Delegate participant filtering to ChallengeHelper
List<Challenge__c> filteredChallenges = ChallengeHelper.filterChallengesByParticipant(
List<AmyDataKit__Challenge__c> filteredChallenges = ChallengeHelper.filterChallengesByParticipant(
challenges,
queryInput.participantRole,
queryInput.participantName
);

if (filteredChallenges.isEmpty()) {
results.add(new Output(new List<Challenge__c>(), 'No challenges found'));
results.add(new Output(new List<AmyDataKit__Challenge__c>(), 'No challenges found'));
} else {
results.add(new Output(filteredChallenges, 'Challenges retrieved successfully'));
}
Expand Down
28 changes: 15 additions & 13 deletions force-app/main/default/classes/helpers/ChallengeHelper.cls
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
public with sharing class ChallengeHelper {
public static List<Challenge__c> queryChallenges(
public static List<AmyDataKit__Challenge__c> queryChallenges(
String status,
Date startDate,
Date endDate,
String id,
String name,
String manager
) {
String query = 'SELECT Id, Name, Status__c, Type__c, Description__c, Result__c, SlackChannel__c, StartDate__c, EndDate__c, Manager__c, Manager__r.Name, Participants__c, Reward__c FROM Challenge__c';
String query = 'SELECT Id, Name, AmyDataKit__Status__c, AmyDataKit__Type__c, AmyDataKit__Description__c, AmyDataKit__Result__c, AmyDataKit__SlackChannel__c, AmyDataKit__StartDate__c, AmyDataKit__EndDate__c, AmyDataKit__Manager__c, AmyDataKit__Manager__r.Name, AmyDataKit__Participants__c, AmyDataKit__Reward__c FROM AmyDataKit__Challenge__c';
List<String> conditions = new List<String>();

// Build query conditions based on input
if (status != null) {
conditions.add('Status__c = :status');
conditions.add('AmyDataKit__Status__c = :status');
}
if (startDate != null) {
conditions.add('StartDate__c >= :startDate');
conditions.add('AmyDataKit__StartDate__c >= :startDate');
}
if (endDate != null) {
conditions.add('EndDate__c <= :endDate');
conditions.add('AmyDataKit__EndDate__c <= :endDate');
}
if (id != null) {
conditions.add('Id = :id');
Expand All @@ -29,7 +29,7 @@ public with sharing class ChallengeHelper {
}
if (manager != null) {
String likeManager = '%' + manager + '%';
conditions.add('Manager__r.Name LIKE :likeManager');
conditions.add('AmyDataKit__Manager__r.Name LIKE :likeManager');
}

// If no conditions, return empty results
Expand All @@ -41,8 +41,8 @@ public with sharing class ChallengeHelper {
return Database.query(query);
}

public static List<Challenge__c> filterChallengesByParticipant(
List<Challenge__c> challenges,
public static List<AmyDataKit__Challenge__c> filterChallengesByParticipant(
List<AmyDataKit__Challenge__c> challenges,
String participantRole,
String participantName
) {
Expand All @@ -52,13 +52,15 @@ public with sharing class ChallengeHelper {

String participantRoleFilter = participantRole != null ? participantRole.toLowerCase().trim() : null;
String participantNameFilter = participantName != null ? participantName.toLowerCase().trim() : null;
List<Challenge__c> filteredChallenges = new List<Challenge__c>();
List<AmyDataKit__Challenge__c> filteredChallenges = new List<AmyDataKit__Challenge__c>();

for (Challenge__c challenge : challenges) {
for (AmyDataKit__Challenge__c challenge : challenges) {
if (
challenge.Participants__c != null &&
((participantRoleFilter != null && challenge.Participants__c.toLowerCase().contains(participantRoleFilter)) ||
(participantNameFilter != null && challenge.Participants__c.toLowerCase().contains(participantNameFilter)))
challenge.AmyDataKit__Participants__c != null &&
((participantRoleFilter != null &&
challenge.AmyDataKit__Participants__c.toLowerCase().contains(participantRoleFilter)) ||
(participantNameFilter != null &&
challenge.AmyDataKit__Participants__c.toLowerCase().contains(participantNameFilter)))
) {
filteredChallenges.add(challenge);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public with sharing class OpportunityHelper {
Boolean isClosed,
Boolean isWon
) {
String query = 'SELECT Id, Name, Owner.Name, OwnerId, Amount, Type, CloseDate, StageName, Difficulty__c, Description FROM Opportunity';
String query = 'SELECT Id, Name, Owner.Name, OwnerId, Amount, Type, CloseDate, StageName, AmyDataKit__Difficulty__c, Description FROM Opportunity';
List<String> conditions = new List<String>();

// Build query conditions based on input
Expand Down
4 changes: 2 additions & 2 deletions force-app/main/default/classes/helpers/SlackHelper.cls
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public with sharing class SlackHelper {
ReturnToken result = new ReturnToken();

SlackBotToken__mdt tokenMetadata = [
SELECT Bot_User_OAuth_Token__c
FROM SlackBotToken__mdt
SELECT AmyDataKit__Bot_User_OAuth_Token__c
FROM AmyDataKit__SlackBotToken__mdt
WHERE DeveloperName = :agentName
LIMIT 1
];
Expand Down