Skip to content

Commit d86c3c5

Browse files
authored
Merge pull request #7230 from Countly/period-obj
[core] Fix period calculation
2 parents 23f24f6 + f508f5e commit d86c3c5

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Version 25.03.X
2+
Fixes:
3+
- [core] Fix period calculation
4+
15
## Version 25.03.33
26
Fixes:
37
- [compliance-hub] Correctly merge user history on user merge

api/lib/countly.common.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ function getUniqArray(weeksArray_pd, weekCounts_pd, monthsArray_pd, monthCounts_
107107

108108
if (weekCounts[key] < 7) {
109109
for (i = 0; i < weeksArray.length; i++) {
110-
weeksArray[i] = weeksArray[i].replace(key, 0);
110+
if (weeksArray[i] === key) {
111+
weeksArray[i] = '0';
112+
}
111113
}
112114
}
113115
}
@@ -126,7 +128,9 @@ function getUniqArray(weeksArray_pd, weekCounts_pd, monthsArray_pd, monthCounts_
126128

127129
if (monthCounts[key] < tmpDaysInMonth) {
128130
for (i = 0; i < monthsArray.length; i++) {
129-
monthsArray[i] = monthsArray[i].replace(key, 0);
131+
if (monthsArray[i] === key) {
132+
monthsArray[i] = '0';
133+
}
130134
}
131135
}
132136
}
@@ -226,7 +230,9 @@ function getUniqCheckArray(weeksArray_pd, weekCounts_pd, monthsArray_pd, monthCo
226230

227231
if (weekCounts[key] < 1) {
228232
for (i = 0; i < weeksArray.length; i++) {
229-
weeksArray[i] = weeksArray[i].replace(key, 0);
233+
if (weeksArray[i] === key) {
234+
weeksArray[i] = '0';
235+
}
230236
}
231237
}
232238
}
@@ -245,7 +251,9 @@ function getUniqCheckArray(weeksArray_pd, weekCounts_pd, monthsArray_pd, monthCo
245251

246252
if (monthCounts[key] < (tmpDaysInMonth * 0.5)) {
247253
for (i = 0; i < monthsArray.length; i++) {
248-
monthsArray[i] = monthsArray[i].replace(key, 0);
254+
if (monthsArray[i] === key) {
255+
monthsArray[i] = '0';
256+
}
249257
}
250258
}
251259
}

0 commit comments

Comments
 (0)