Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing isEnabled__c as a feature #160

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
1 change: 0 additions & 1 deletion docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Here is how the new custom achievement can be configured:
* UIDescription__c - Achievement description that is going to be shown to user once he unlocks the achievement
* Goal__c - Goal that need to be reached by user for achievement to be treated as unlocked/reached. For example, our standard "Create 10 Leads" achievement has a Goal__c set to 10 and is related to relevant measurement called "CreatedLeadsCounter". Once user has 10 Created Leads - achievement is going to be treated as unlocked.
* Score__c - Number of points that user gets for unlocking an achievement. Used for leaderboards.
* Enabled__c - Allows Admin users to enable/disable achievements without removing data from the system.
3. Once both Measurement and Achievement are defined, you can now define the logic for your new measurement to be increased per each user. This can be done in a trigger or by no-code tools built into Salesforce. In the end, each time the metric is expected to be increased for a specific user `UserMeasurementIncrement__e` platform event has to be fired by your custom logic.
`UserMeasurementIncrement__e` fields:
* Increment__c - number of points to increment/decrement from a user measurement
Expand Down
2 changes: 1 addition & 1 deletion force-app/main/default/classes/AchievementSelector.cls
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public with sharing class AchievementSelector extends BaseSelector {
}

public override Set<String> fieldApiNames() {
return new Set<String> {'Id', 'Name', 'Description__c', 'Enabled__c', 'Goal__c', 'Score__c', 'UITitle__c', 'UIDescription__c', 'Measurement__c'};
return new Set<String> {'Id', 'Name', 'Description__c', 'Goal__c', 'Score__c', 'UITitle__c', 'UIDescription__c', 'Measurement__c'};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private class AchievementSelectorTest {
Test.stopTest();

// Then
Set<String> expectedSet = new Set<String> {'Id', 'Name', 'Description__c', 'Enabled__c', 'Goal__c', 'Score__c', 'UITitle__c', 'UIDescription__c', 'Measurement__c'};
Set<String> expectedSet = new Set<String> {'Id', 'Name', 'Description__c', 'Goal__c', 'Score__c', 'UITitle__c', 'UIDescription__c', 'Measurement__c'};
system.assertEquals(expectedSet, result, 'A specific field set is expected');
}
}
54 changes: 18 additions & 36 deletions force-app/main/default/classes/GameForceConfig.cls
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Created 10 Leads',
Description__c = 'Standard Achievement, that can be reached by creating 10 different Leads',
Goal__c = 10,
Score__c = 10,
Enabled__c = true);
Score__c = 10);
achievementsToInsert.add(created10Leads);

Achievement__c created50Leads = new Achievement__c(
Expand All @@ -49,8 +48,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Created 50 Leads',
Description__c = 'Standard Achievement, that can be reached by creating 50 different Leads',
Goal__c = 50,
Score__c = 20,
Enabled__c = true);
Score__c = 20);
achievementsToInsert.add(created50Leads);

Achievement__c created100Leads = new Achievement__c(
Expand All @@ -60,8 +58,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Created 100 Leads',
Description__c = 'Standard Achievement, that can be reached by creating 100 different Leads',
Goal__c = 100,
Score__c = 50,
Enabled__c = true);
Score__c = 50);
achievementsToInsert.add(created100Leads);

Achievement__c created200Leads = new Achievement__c(
Expand All @@ -71,8 +68,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Created 200 Leads',
Description__c = 'Standard Achievement, that can be reached by creating 200 different Leads',
Goal__c = 200,
Score__c = 100,
Enabled__c = true);
Score__c = 100);
achievementsToInsert.add(created200Leads);

// Converted Leads achievements
Expand All @@ -83,8 +79,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Converted 10 Leads',
Description__c = 'Standard Achievement, that can be reached by converting 10 different Leads to Accounts/Contacts/Opportunities',
Goal__c = 10,
Score__c = 10,
Enabled__c = true);
Score__c = 10);
achievementsToInsert.add(converted10Leads);

Achievement__c converted50Leads = new Achievement__c(
Expand All @@ -94,8 +89,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Converted 50 Leads',
Description__c = 'Standard Achievement, that can be reached by converting 50 different Leads to Accounts/Contacts/Opportunities',
Goal__c = 50,
Score__c = 20,
Enabled__c = true);
Score__c = 20);
achievementsToInsert.add(converted50Leads);

Achievement__c converted100Leads = new Achievement__c(
Expand All @@ -105,8 +99,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Converted 100 Leads',
Description__c = 'Standard Achievement, that can be reached by converting 100 different Leads to Accounts/Contacts/Opportunities',
Goal__c = 100,
Score__c = 100,
Enabled__c = true);
Score__c = 100);
achievementsToInsert.add(converted100Leads);

// Completed Tasks achievements
Expand All @@ -117,8 +110,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Complete 10 Tasks',
Description__c = 'Standard Achievement, that can be reached by completing 10 different tasks',
Goal__c = 10,
Score__c = 10,
Enabled__c = true);
Score__c = 10);
achievementsToInsert.add(complete10Tasks);

Achievement__c complete50Tasks = new Achievement__c(
Expand All @@ -128,8 +120,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Complete 50 Tasks',
Description__c = 'Standard Achievement, that can be reached by completing 50 different tasks',
Goal__c = 50,
Score__c = 20,
Enabled__c = true);
Score__c = 20);
achievementsToInsert.add(complete50Tasks);

Achievement__c complete100Tasks = new Achievement__c(
Expand All @@ -139,8 +130,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Complete 100 Tasks',
Description__c = 'Standard Achievement, that can be reached by completing 100 different tasks',
Goal__c = 100,
Score__c = 20,
Enabled__c = true);
Score__c = 20);
achievementsToInsert.add(complete100Tasks);

Achievement__c complete200Tasks = new Achievement__c(
Expand All @@ -150,8 +140,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Complete 200 Tasks',
Description__c = 'Standard Achievement, that can be reached by completing 200 different tasks',
Goal__c = 200,
Score__c = 100,
Enabled__c = true);
Score__c = 100);
achievementsToInsert.add(complete200Tasks);

// Posted chatted posts achievements
Expand All @@ -162,8 +151,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Create 10 Chatter posts',
Description__c = 'Standard Achievement, that can be reached by creating 10 posts in Chatter',
Goal__c = 10,
Score__c = 10,
Enabled__c = true);
Score__c = 10);
achievementsToInsert.add(chatter10Posts);

Achievement__c chatter50Posts = new Achievement__c(
Expand All @@ -173,8 +161,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Create 50 Chatter posts',
Description__c = 'Standard Achievement, that can be reached by creating 50 posts in Chatter',
Goal__c = 50,
Score__c = 10,
Enabled__c = true);
Score__c = 10);
achievementsToInsert.add(chatter50Posts);

Achievement__c chatter100Posts = new Achievement__c(
Expand All @@ -184,8 +171,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Create 100 Chatter posts',
Description__c = 'Standard Achievement, that can be reached by creating 100 posts in Chatter',
Goal__c = 100,
Score__c = 20,
Enabled__c = true);
Score__c = 20);
achievementsToInsert.add(chatter100Posts);

Achievement__c chatter200Posts = new Achievement__c(
Expand All @@ -195,8 +181,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Create 200 Chatter posts',
Description__c = 'Standard Achievement, that can be reached by creating 200 posts in Chatter',
Goal__c = 200,
Score__c = 50,
Enabled__c = true);
Score__c = 50);
achievementsToInsert.add(chatter200Posts);

Achievement__c case10Closed = new Achievement__c(
Expand All @@ -206,8 +191,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Close 10 cases',
Description__c = 'Standard Achievement, that can be reached by closing 10 Cases',
Goal__c = 10,
Score__c = 10,
Enabled__c = true);
Score__c = 10);
achievementsToInsert.add(case10Closed);

Achievement__c case50Closed = new Achievement__c(
Expand All @@ -217,8 +201,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Close 50 cases',
Description__c = 'Standard Achievement, that can be reached by closing 50 Cases',
Goal__c = 50,
Score__c = 20,
Enabled__c = true);
Score__c = 20);
achievementsToInsert.add(case50Closed);

Achievement__c case100Closed = new Achievement__c(
Expand All @@ -228,8 +211,7 @@ public with sharing class GameForceConfig implements InstallHandler {
UIDescription__c = 'Close 100 cases',
Description__c = 'Standard Achievement, that can be reached by closing 50 Cases',
Goal__c = 100,
Score__c = 100,
Enabled__c = true);
Score__c = 100);
achievementsToInsert.add(case100Closed);

insert achievementsToInsert;
Expand Down
1 change: 0 additions & 1 deletion force-app/main/default/classes/TestDataFactory.cls
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class TestDataFactory {
Achievement__c achievement = new Achievement__c();
achievement.Name = 'Name ' + uniqueIdentifier;
achievement.Description__c = 'Generic description ' + uniqueIdentifier;
achievement.Enabled__c = true;
achievement.Goal__c = 100 + Math.round(1000 * Math.random());
achievement.Score__c = 100 + Math.round(1000 * Math.random());
achievement.UITitle__c = 'UI Title ' + uniqueIdentifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
<behavior>Edit</behavior>
<field>Score__c</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>Enabled__c</field>
</layoutItems>
</layoutColumns>
<layoutColumns>
<layoutItems>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<columns>NAME</columns>
<columns>UITitle__c</columns>
<columns>UIDescription__c</columns>
<columns>Enabled__c</columns>
<columns>Measurement__c</columns>
<columns>Goal__c</columns>
<columns>Score__c</columns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<field>Achievement__c.Description__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>Achievement__c.Enabled__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>Achievement__c.Score__c</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<field>Achievement__c.Description__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>Achievement__c.Enabled__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>Achievement__c.Score__c</field>
Expand Down
Loading