Skip to content

Commit

Permalink
Rename MilestoneProgressEntry to CampaignMilestoneProgressEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
ammopt committed Nov 7, 2024
1 parent e73aee1 commit befae78
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion code/web/services/MyAccount/MyCampaigns.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function getCampaigns() {

//Calculate milestone progress
$milestoneProgress = CampaignMilestone::getMilestoneProgress($campaignId, $userId, $milestone->id);
$progressData = MilestoneProgressEntry::getUserProgressDataByMilestoneId($userId, $milestoneId);
$progressData = CampaignMilestoneProgressEntry::getUserProgressDataByMilestoneId($userId, $milestoneId);

$milestone->progress = $milestoneProgress['progress'];
$milestone->completedGoals = $milestoneProgress['completed'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
require_once ROOT_DIR . '/sys/Community/Milestone.php';

class MilestoneProgressEntry extends DataObject
class CampaignMilestoneProgressEntry extends DataObject
{
public $__table = 'ce_milestone_progress_entries';
public $__table = 'ce_campaign_milestone_progress_entries';
public $id;
public $userId;
public $ce_milestone_id;
Expand All @@ -13,7 +13,7 @@ class MilestoneProgressEntry extends DataObject
public $object;

/**
* Initializes a new MilestoneProgressEntry object by setting its ce_milestone_id to the provided milestone object
* Initializes a new CampaignMilestoneProgressEntry object by setting its ce_milestone_id to the provided milestone object
*
* @param Milestone $milestone The milestone associated with this progress entry.
* @param mixed $args Optional arguments to further configure the progress entry. Expects the following structure:
Expand Down Expand Up @@ -43,17 +43,17 @@ public function initialize(Milestone $milestone, $args = null)
}

public static function getUserProgressDataByMilestoneId($userId, $milestoneId) {
$milestoneProgressEntry = new self();
$milestoneProgressEntry->whereAdd("userId = " . $userId);
$milestoneProgressEntry->whereAdd("ce_milestone_id = " . $milestoneId);
$campaignMilestoneProgressEntry = new self();
$campaignMilestoneProgressEntry->whereAdd("userId = " . $userId);
$campaignMilestoneProgressEntry->whereAdd("ce_milestone_id = " . $milestoneId);

$results = [];
if ($milestoneProgressEntry->find()) {
if ($campaignMilestoneProgressEntry->find()) {
$decodedObject = [];
while ($milestoneProgressEntry->fetch()) {
$decodedObject = json_decode($milestoneProgressEntry->object, true);
while ($campaignMilestoneProgressEntry->fetch()) {
$decodedObject = json_decode($campaignMilestoneProgressEntry->object, true);
if ($decodedObject) {
$results[$milestoneProgressEntry->id] = $decodedObject;
$results[$campaignMilestoneProgressEntry->id] = $decodedObject;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions code/web/sys/Community/Milestone.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ public static function getMilestonesToUpdate($object, $tableName, $userId)
}

/**
* Adds a new MilestoneProgressEntry for a given milestone, object, and user.
* Adds a new CampaignMilestoneProgressEntry for a given milestone, object, and user.
*
* @param Milestone $milestone The milestone associated with this progress entry.
* @param mixed $object The object associated with this progress entry.
* @param int $userId The user id associated with this progress entry.
*/
public function addMilestoneProgressEntry( $object, $userId)
public function addCampaignMilestoneProgressEntry( $object, $userId)
{
require_once ROOT_DIR . '/sys/Community/UserCampaign.php';

Expand All @@ -188,8 +188,8 @@ public function addMilestoneProgressEntry( $object, $userId)
$milestoneUsersProgress->insert();
}

$milestoneProgressEntry = new MilestoneProgressEntry();
$milestoneProgressEntry->initialize(
$campaignMilestoneProgressEntry = new CampaignMilestoneProgressEntry();
$campaignMilestoneProgressEntry->initialize(
$this,
[
"object" => $object,
Expand Down
12 changes: 6 additions & 6 deletions code/web/sys/Community/action-hooks.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

require_once ROOT_DIR . '/sys/Community/Milestone.php';
require_once ROOT_DIR . '/sys/Community/MilestoneProgressEntry.php';
require_once ROOT_DIR . '/sys/Community/CampaignMilestoneProgressEntry.php';

/**
* after_checkout_insert
Expand All @@ -21,7 +21,7 @@
if (_milestoneProgressEntryObjectAlreadyExists($value, $milestone))
return;

$milestone->addMilestoneProgressEntry($value, $value->userId);
$milestone->addCampaignMilestoneProgressEntry($value, $value->userId);
}
return;
});
Expand All @@ -44,7 +44,7 @@
if (_milestoneProgressEntryObjectAlreadyExists($value, $milestone))
return;

$milestone->addMilestoneProgressEntry($value, $value->userId);
$milestone->addCampaignMilestoneProgressEntry($value, $value->userId);
}
return;
});
Expand All @@ -64,7 +64,7 @@
return;

while ($milestone->fetch()) {
$milestone->addMilestoneProgressEntry($value, $value->user_id);
$milestone->addCampaignMilestoneProgressEntry($value, $value->user_id);
}
return;
});
Expand All @@ -84,7 +84,7 @@
return;

while ($milestone->fetch()) {
$milestone->addMilestoneProgressEntry($value, $value->userId);
$milestone->addCampaignMilestoneProgressEntry($value, $value->userId);
}
return;
});
Expand All @@ -100,7 +100,7 @@
*/
function _milestoneProgressEntryObjectAlreadyExists($value, $milestone)
{
$milestoneProgressEntryCheck = new MilestoneProgressEntry();
$milestoneProgressEntryCheck = new CampaignMilestoneProgressEntry();
$milestoneProgressEntryCheck->initialize($milestone);
if ($milestoneProgressEntryCheck->find()) {
while ($milestoneProgressEntryCheck->fetch()) {
Expand Down
6 changes: 3 additions & 3 deletions code/web/sys/DBMaintenance/community_engagement_updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ function getCommunityEngagementUpdates() {
)ENGINE = InnoDB",
],
],
'add_ce_milestone_progress_entries' => [
'title' => 'Add add_ce_milestone_progress_entries database table',
'add_ce_campaign_milestone_progress_entries' => [
'title' => 'Add add_ce_campaign_milestone_progress_entries database table',
'description' => 'Store milestone progress entries to be processed by cronjob',
'sql' => [
"CREATE TABLE IF NOT EXISTS ce_milestone_progress_entries (
"CREATE TABLE IF NOT EXISTS ce_campaign_milestone_progress_entries (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
userId INT NOT NULL,
ce_milestone_id INT NOT NULL,
Expand Down

0 comments on commit befae78

Please sign in to comment.