Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
217
Issues
217
List
Boards
Labels
Service Desk
Milestones
Merge Requests
32
Merge Requests
32
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Compare Revisions
0628b4d29fb48302ad26c07fa7b36532602c571b...343a3648ac0c22a12f802c0275a6a03f2a6f3620
Source
343a3648ac0c22a12f802c0275a6a03f2a6f3620
Select Git revision
...
Target
0628b4d29fb48302ad26c07fa7b36532602c571b
Select Git revision
Compare
Commits (3)
(chore) Fix up broken test and add test for the active users query builder -
#590
· 9252c893
Guy Thouret
authored
19 minutes ago
9252c893
(chore) Remove debug code from UpdateUserStateEstimate and simplify notification logic -
#590
· 163b8a2f
Guy Thouret
authored
18 minutes ago
163b8a2f
(chore) Spacing in ActiveUsersIterator -
#590
· 343a3648
Guy Thouret
authored
17 minutes ago
343a3648
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
178 additions
and
118 deletions
+178
-118
UpdateUserStateEstimate.php
Core/Analytics/Delegates/UpdateUserStateEstimate.php
+1
-11
ActiveUsersIterator.php
Core/Analytics/UserStates/ActiveUsersIterator.php
+1
-0
ActiveUsersQueryBuilderSpec.php
...Core/Analytics/UserStates/ActiveUsersQueryBuilderSpec.php
+100
-0
active_users_query.json
...ore/Analytics/UserStates/MockData/active_users_query.json
+35
-51
active_users_results.json
...e/Analytics/UserStates/MockData/active_users_results.json
+41
-56
No files found.
Core/Analytics/Delegates/UpdateUserStateEstimate.php
View file @
343a3648
...
...
@@ -44,17 +44,7 @@ class UpdateUserStateEstimate
private
function
sendStateChangeNotification
()
:
void
{
$data
=
[
$this
->
user
->
getGUID
(),
$this
->
user
->
getUserState
(),
$this
->
user
->
getUserStateToday
(),
$this
->
userState
->
getStateChange
(),
$this
->
estimateStateChange
];
error_log
(
implode
(
'|'
,
$data
));
if
(
$this
->
estimateStateChange
<
0
&&
$this
->
userState
->
getStateChange
()
<
0
)
{
if
(
$this
->
estimateStateChange
<
0
)
{
$notificationView
=
'rewards_state_decrease_today'
;
Dispatcher
::
trigger
(
'notification'
,
'reward'
,
[
'to'
=>
[
...
...
This diff is collapsed.
Click to expand it.
Core/Analytics/UserStates/ActiveUsersIterator.php
View file @
343a3648
...
...
@@ -98,6 +98,7 @@ class ActiveUsersIterator implements \Iterator
$userActivityBuckets
->
setActiveDaysBuckets
(
$days
);
$this
->
data
[]
=
$userActivityBuckets
;
}
if
(
$this
->
cursor
>=
count
(
$this
->
data
))
{
$this
->
get
();
}
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Analytics/UserStates/ActiveUsersQueryBuilderSpec.php
0 → 100644
View file @
343a3648
<?php
namespace
Spec\Minds\Core\Analytics\UserStates
;
use
Minds\Core\Analytics\UserStates\ActiveUsersQueryBuilder
;
use
PhpSpec\ObjectBehavior
;
class
ActiveUsersQueryBuilderSpec
extends
ObjectBehavior
{
public
function
it_is_initializable
()
{
$this
->
shouldHaveType
(
ActiveUsersQueryBuilder
::
class
);
}
public
function
it_should_produce_a_valid_query
()
{
$from
=
strtotime
(
'midnight -2 days'
);
$to
=
strtotime
(
'midnight'
);
$this
->
setPartitions
(
10
)
->
setPage
(
2
)
->
setFrom
(
$from
)
->
setTo
(
$to
)
->
query
()
->
shouldBe
(
$this
->
exampleQuery
());
}
private
function
exampleQuery
()
:
array
{
$query
=
'{
"index": "minds-metrics-*",
"size": "0",
"body": {
"query": {
"bool": {
"must": [
{
"match_phrase": {
"action.keyword": {
"query": "active"
}
}
},
{
"range": {
"@timestamp": {
"from": 1568073600000,
"to": 1568246400000,
"format": "epoch_millis"
}
}
}
]
}
},
"aggs": {
"users": {
"terms": {
"field": "user_guid.keyword",
"size": 5000,
"include": {
"partition": 2,
"num_partitions": 10
}
},
"aggs": {
"1568160000": {
"date_range": {
"field": "@timestamp",
"ranges": [
{
"from": 1568160000000,
"to": 1568246400000
}
]
}
},
"count-1568160000": {
"sum_bucket": {
"buckets_path": "1568160000>_count"
}
},
"1568246400": {
"date_range": {
"field": "@timestamp",
"ranges": [
{
"from": 1568246400000,
"to": 1568332800000
}
]
}
},
"count-1568246400": {
"sum_bucket": {
"buckets_path": "1568246400>_count"
}
}
}
}
}
}
}'
;
return
json_decode
(
$query
,
true
);
}
}
This diff is collapsed.
Click to expand it.
Spec/Core/Analytics/UserStates/MockData/active_users_query.json
View file @
343a3648
...
...
@@ -16,7 +16,7 @@
"range"
:
{
"@timestamp"
:
{
"from"
:
1548892800000
,
"to"
:
1549
5840
00000
,
"to"
:
1549
4976
00000
,
"format"
:
"epoch_millis"
}
}
...
...
@@ -35,55 +35,55 @@
}
},
"aggs"
:
{
"
day-0-bucket
"
:
{
"
1548979200
"
:
{
"date_range"
:
{
"field"
:
"@timestamp"
,
"ranges"
:
[
{
"from"
:
154
94976
00000
,
"to"
:
1549
5840
00000
"from"
:
154
89792
00000
,
"to"
:
1549
0656
00000
}
]
}
},
"
day-
0"
:
{
"
count-154897920
0"
:
{
"sum_bucket"
:
{
"buckets_path"
:
"
day-0-bucket
>_count"
"buckets_path"
:
"
1548979200
>_count"
}
},
"
day-1-bucket
"
:
{
"
1549065600
"
:
{
"date_range"
:
{
"field"
:
"@timestamp"
,
"ranges"
:
[
{
"from"
:
1549
4112
00000
,
"to"
:
1549
4976
00000
"from"
:
1549
0656
00000
,
"to"
:
1549
1520
00000
}
]
}
},
"
day-1
"
:
{
"
count-1549065600
"
:
{
"sum_bucket"
:
{
"buckets_path"
:
"
day-1-bucket
>_count"
"buckets_path"
:
"
1549065600
>_count"
}
},
"
day-2-bucket
"
:
{
"
1549152000
"
:
{
"date_range"
:
{
"field"
:
"@timestamp"
,
"ranges"
:
[
{
"from"
:
1549
3248
00000
,
"to"
:
1549
4112
00000
"from"
:
1549
1520
00000
,
"to"
:
1549
2384
00000
}
]
}
},
"
day-2
"
:
{
"
count-1549152000
"
:
{
"sum_bucket"
:
{
"buckets_path"
:
"
day-2-bucket
>_count"
"buckets_path"
:
"
1549152000
>_count"
}
},
"
day-3-bucket
"
:
{
"
1549238400
"
:
{
"date_range"
:
{
"field"
:
"@timestamp"
,
"ranges"
:
[
...
...
@@ -94,77 +94,61 @@
]
}
},
"
day-3
"
:
{
"
count-1549238400
"
:
{
"sum_bucket"
:
{
"buckets_path"
:
"
day-3-bucket
>_count"
"buckets_path"
:
"
1549238400
>_count"
}
},
"
day-4-bucket
"
:
{
"
1549324800
"
:
{
"date_range"
:
{
"field"
:
"@timestamp"
,
"ranges"
:
[
{
"from"
:
1549152000000
,
"to"
:
1549238400000
}
]
}
},
"day-4"
:
{
"sum_bucket"
:
{
"buckets_path"
:
"day-4-bucket>_count"
}
},
"day-5-bucket"
:
{
"date_range"
:
{
"field"
:
"@timestamp"
,
"ranges"
:
[
{
"from"
:
1549065600000
,
"to"
:
1549152000000
"from"
:
1549324800000
,
"to"
:
1549411200000
}
]
}
},
"
day-5
"
:
{
"
count-1549324800
"
:
{
"sum_bucket"
:
{
"buckets_path"
:
"
day-5-bucket
>_count"
"buckets_path"
:
"
1549324800
>_count"
}
},
"
day-6-bucket
"
:
{
"
1549411200
"
:
{
"date_range"
:
{
"field"
:
"@timestamp"
,
"ranges"
:
[
{
"from"
:
154
8979
200000
,
"to"
:
1549
065
600000
"from"
:
154
9411
200000
,
"to"
:
1549
497
600000
}
]
}
},
"
day-6
"
:
{
"
count-1549411200
"
:
{
"sum_bucket"
:
{
"buckets_path"
:
"
day-6-bucket
>_count"
"buckets_path"
:
"
1549411200
>_count"
}
},
"
day-7-bucket
"
:
{
"
1549497600
"
:
{
"date_range"
:
{
"field"
:
"@timestamp"
,
"ranges"
:
[
{
"from"
:
154
88928
00000
,
"to"
:
154
89792
00000
"from"
:
154
94976
00000
,
"to"
:
154
95840
00000
}
]
}
},
"
day-7
"
:
{
"
count-1549497600
"
:
{
"sum_bucket"
:
{
"buckets_path"
:
"
day-7-bucket
>_count"
"buckets_path"
:
"
1549497600
>_count"
}
}
}
}
}
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
Spec/Core/Analytics/UserStates/MockData/active_users_results.json
View file @
343a3648
...
...
@@ -20,31 +20,19 @@
{
"key"
:
"934155581860614163"
,
"doc_count"
:
1
,
"
day-2-bucket
"
:
{
"
1548979200
"
:
{
"buckets"
:
[
{
"key"
:
"2019-02-0
5T00:00:00.000Z-2019-02-06
T00:00:00.000Z"
,
"from"
:
154
93248
00000
,
"from_as_string"
:
"2019-02-0
5
T00:00:00.000Z"
,
"to"
:
1549
4112
00000
,
"to_as_string"
:
"2019-02-0
6
T00:00:00.000Z"
,
"key"
:
"2019-02-0
1T00:00:00.000Z-2019-02-02
T00:00:00.000Z"
,
"from"
:
154
89792
00000
,
"from_as_string"
:
"2019-02-0
1
T00:00:00.000Z"
,
"to"
:
1549
0656
00000
,
"to_as_string"
:
"2019-02-0
2
T00:00:00.000Z"
,
"doc_count"
:
0
}
]
},
"day-1-bucket"
:
{
"buckets"
:
[
{
"key"
:
"2019-02-06T00:00:00.000Z-2019-02-07T00:00:00.000Z"
,
"from"
:
1549411200000
,
"from_as_string"
:
"2019-02-06T00:00:00.000Z"
,
"to"
:
1549497600000
,
"to_as_string"
:
"2019-02-07T00:00:00.000Z"
,
"doc_count"
:
1
}
]
},
"day-5-bucket"
:
{
"1549065600"
:
{
"buckets"
:
[
{
"key"
:
"2019-02-02T00:00:00.000Z-2019-02-03T00:00:00.000Z"
,
...
...
@@ -56,19 +44,19 @@
}
]
},
"
day-7-bucket
"
:
{
"
1549152000
"
:
{
"buckets"
:
[
{
"key"
:
"2019-0
1-31T00:00:00.000Z-2019-02-01
T00:00:00.000Z"
,
"from"
:
154
88928
00000
,
"from_as_string"
:
"2019-0
1-31
T00:00:00.000Z"
,
"to"
:
154
89792
00000
,
"to_as_string"
:
"2019-02-0
1
T00:00:00.000Z"
,
"key"
:
"2019-0
2-03T00:00:00.000Z-2019-02-04
T00:00:00.000Z"
,
"from"
:
154
91520
00000
,
"from_as_string"
:
"2019-0
2-03
T00:00:00.000Z"
,
"to"
:
154
92384
00000
,
"to_as_string"
:
"2019-02-0
4
T00:00:00.000Z"
,
"doc_count"
:
0
}
]
},
"
day-3-bucket
"
:
{
"
1549238400
"
:
{
"buckets"
:
[
{
"key"
:
"2019-02-04T00:00:00.000Z-2019-02-05T00:00:00.000Z"
,
...
...
@@ -80,68 +68,65 @@
}
]
},
"
day-0-bucket
"
:
{
"
1549324800
"
:
{
"buckets"
:
[
{
"key"
:
"2019-02-0
7T00:00:00.000Z-2019-02-08
T00:00:00.000Z"
,
"from"
:
1549
4976
00000
,
"from_as_string"
:
"2019-02-0
7
T00:00:00.000Z"
,
"to"
:
1549
5840
00000
,
"to_as_string"
:
"2019-02-0
8
T00:00:00.000Z"
,
"key"
:
"2019-02-0
5T00:00:00.000Z-2019-02-06
T00:00:00.000Z"
,
"from"
:
1549
3248
00000
,
"from_as_string"
:
"2019-02-0
5
T00:00:00.000Z"
,
"to"
:
1549
4112
00000
,
"to_as_string"
:
"2019-02-0
6
T00:00:00.000Z"
,
"doc_count"
:
0
}
]
},
"
day-6-bucket
"
:
{
"
1549411200
"
:
{
"buckets"
:
[
{
"key"
:
"2019-02-0
1T00:00:00.000Z-2019-02-02
T00:00:00.000Z"
,
"from"
:
154
8979
200000
,
"from_as_string"
:
"2019-02-0
1
T00:00:00.000Z"
,
"to"
:
1549
065
600000
,
"to_as_string"
:
"2019-02-0
2
T00:00:00.000Z"
,
"doc_count"
:
0
"key"
:
"2019-02-0
6T00:00:00.000Z-2019-02-07
T00:00:00.000Z"
,
"from"
:
154
9411
200000
,
"from_as_string"
:
"2019-02-0
6
T00:00:00.000Z"
,
"to"
:
1549
497
600000
,
"to_as_string"
:
"2019-02-0
7
T00:00:00.000Z"
,
"doc_count"
:
1
}
]
},
"
day-4-bucket
"
:
{
"
1549497600
"
:
{
"buckets"
:
[
{
"key"
:
"2019-02-0
3T00:00:00.000Z-2019-02-04
T00:00:00.000Z"
,
"from"
:
1549
1520
00000
,
"from_as_string"
:
"2019-02-0
3
T00:00:00.000Z"
,
"to"
:
1549
2384
00000
,
"to_as_string"
:
"2019-02-0
4
T00:00:00.000Z"
,
"key"
:
"2019-02-0
7T00:00:00.000Z-2019-02-08
T00:00:00.000Z"
,
"from"
:
1549
4976
00000
,
"from_as_string"
:
"2019-02-0
7
T00:00:00.000Z"
,
"to"
:
1549
5840
00000
,
"to_as_string"
:
"2019-02-0
8
T00:00:00.000Z"
,
"doc_count"
:
0
}
]
},
"day-0"
:
{
"value"
:
0
},
"day-1"
:
{
"count-1548979200"
:
{
"value"
:
1
},
"
day-2
"
:
{
"
count-1549065600
"
:
{
"value"
:
0
},
"
day-3
"
:
{
"
count-1549152000
"
:
{
"value"
:
0
},
"
day-4
"
:
{
"
count-1549238400
"
:
{
"value"
:
0
},
"
day-5
"
:
{
"
count-1549324800
"
:
{
"value"
:
0
},
"
day-6
"
:
{
"
count-1549411200
"
:
{
"value"
:
0
},
"
day-7
"
:
{
"
count-1549497600
"
:
{
"value"
:
0
}
}
]
}
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.