Skip to content

Commit e2ed242

Browse files
committed
tweaks for add/update/remove functions. Thanks Rick Hoover
1 parent 92cf42c commit e2ed242

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

src/Users/UserStatistics.php

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getStatistic($typeCode,$categoryCode)
5656
*
5757
* @return Statistic
5858
*/
59-
public function addStatisticRaw($typeCode,$typeDesc,$categoryCode,$categoryDesc,$note,$segment_type)
59+
public function addStatisticRaw($typeCode,$typeDesc,$categoryCode,$categoryDesc,$segment_type,$note)
6060
{
6161
# Create the new statistic object
6262
$stat_obj = (object) [
@@ -76,7 +76,8 @@ public function addStatisticRaw($typeCode,$typeDesc,$categoryCode,$categoryDesc,
7676
$this->data[] = $stat_obj;
7777

7878
/* Not Sure this is quite right or needed. */
79-
return Statistic::make($this->client,$stat_obj);
79+
#return Statistic::make($this->client,$stat_obj);
80+
#return($this->data);
8081
}
8182

8283
/**
@@ -87,7 +88,7 @@ public function addStatisticRaw($typeCode,$typeDesc,$categoryCode,$categoryDesc,
8788
*
8889
* @return Statistic
8990
*/
90-
public function addStatistic($typeCode,$categoryCode)
91+
public function addStatistic($typeCode,$categoryCode,$segmentType,$note)
9192
{
9293
//* TODO HERE *//
9394

@@ -111,13 +112,12 @@ public function addStatistic($typeCode,$categoryCode)
111112
#$typeDesc = $this->conf->CodeTables->getDesc('UserStatisticalTypes',$typeCode);
112113
#$categoryDesc = $this->conf->CodeTables->getDesc('UserStatCagegories',$categoryCode);
113114
#
114-
# These are temporary.
115-
$segmentType = 'External'; # Just for now.
116-
$note = ''; # Just for now.
115+
# These are temporary for testing.
116+
$typeDesc = 'Test';
117+
$categoryDesc = 'Test';
118+
119+
$this->addStatisticRaw($typeCode,$typeDesc,$categoryCode,$categoryDesc,$segmentType,$note);
117120

118-
$ret = $this->addStatisticRaw($typeCode,$typeDesc,$categoryCode,$categoryDesc,$note,$segmentType);
119-
120-
return($ret);
121121
}
122122

123123
/**
@@ -128,29 +128,26 @@ public function addStatistic($typeCode,$categoryCode)
128128
*/
129129
public function removeStatistic($typeCode,$categoryCode)
130130
{
131-
foreach ($this->data->user_statistic as $statistic) {
132-
if (($statistic->category_type->value == $typeCode ) && ($statistic->statistic_category->value == $categoryCode )) {
133-
134-
//* TODO HERE *//
135-
136-
return;
131+
$max = sizeof($this->data);
132+
$ret = false;
133+
for($i = 0; $i < $max; $i++) {
134+
if (($this->data[$i]->category_type->value == $typeCode) && ($this->data[$i]->statistic_category->value == $categoryCode)) {
135+
unset($this->data[$i]);
136+
$ret = true;
137137
}
138138
}
139+
return($ret);
139140
}
140141

141142
/**
142143
* Update a user statistic.
143144
*
144145
*/
145-
public function updateStatistic($fromTypeCode,$fromCategoryCode,$toTypeCode,$toCategoryCode)
146+
public function updateStatistic($fromTypeCode,$fromCategoryCode,$toTypeCode,$toCategoryCode,$segementType,$note)
146147
{
147-
148-
//* TODO HERE *//
149-
150148
/* Remove "from" statistic, then add "to" statistic */
151-
152149
$this->removeStatistic($fromTypeCode,$categoryCode);
153-
$this->addStatistic($toTypeCode,$toCategoryCode);
150+
$this->addStatistic($toTypeCode,$toCategoryCode,$segmentType,$note);
154151
}
155152

156153
/**

0 commit comments

Comments
 (0)