Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
280
Merge Requests
37
CI / CD
Security & Compliance
Packages
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Compare Revisions
c26a72e3888ecc46c49232a9dabcaf9312cffedc...09cddca5e4d08fc2835828eb48657eed9d11458b
Source
09cddca5e4d08fc2835828eb48657eed9d11458b
...
Target
c26a72e3888ecc46c49232a9dabcaf9312cffedc
Compare
Commits (2)
Restore a conditional exception to Boost Manager::getList; Refactor it's spec test a little
· b508c766
Guy Thouret
authored
29 minutes ago
b508c766
Lint Boost Manager
· 09cddca5
Guy Thouret
authored
27 minutes ago
09cddca5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
25 deletions
+25
-25
Core/Boost/Network/Manager.php
View file @
09cddca5
...
...
@@ -70,7 +70,8 @@ class Manager
if
(
$opts
[
'useElastic'
])
{
$response
=
$this
->
elasticRepository
->
getList
(
$opts
);
if
(
$this
->
optStateIsUsedAndValid
(
$opts
))
{
// TODO: Check if it is *really* necessary to re fetch the boosts from cassandra ??
if
(
$this
->
optStateIsUsedAndValid
(
$opts
)
&&
$opts
[
'state'
]
!==
self
::
OPT_STATEQUERY_APPROVED
)
{
$opts
[
'guids'
]
=
array_map
(
function
(
$boost
)
{
return
$boost
->
getGuid
();
},
$response
->
toArray
());
...
...
@@ -114,7 +115,7 @@ class Manager
protected
function
optStateIsValid
(
array
$opts
)
:
bool
{
return
in_array
(
$opts
[
'state'
],
self
::
VALID_OPT_STATEQUERY
);
return
in_array
(
$opts
[
'state'
],
self
::
VALID_OPT_STATEQUERY
,
true
);
}
/**
...
...
This diff is collapsed.
Spec/Core/Boost/Network/ManagerSpec.php
View file @
09cddca5
...
...
@@ -19,7 +19,7 @@ use Minds\Core\Di\Di;
class
ManagerSpec
extends
ObjectBehavior
{
/** @var CassandraRepository */
private
$
r
epository
;
private
$
cassandraR
epository
;
/** @var ElasticRepository */
private
$elasticRepository
;
/** @var EntitiesBuilder */
...
...
@@ -28,13 +28,13 @@ class ManagerSpec extends ObjectBehavior
private
$guidBuilder
;
public
function
let
(
CassandraRepository
$
r
epository
,
CassandraRepository
$
cassandraR
epository
,
ElasticRepository
$elasticRepository
,
EntitiesBuilder
$entitiesBuilder
,
GuidBuilder
$guidBuilder
)
{
$this
->
beConstructedWith
(
$
r
epository
,
$elasticRepository
,
$entitiesBuilder
,
$guidBuilder
);
$this
->
repository
=
$r
epository
;
$this
->
beConstructedWith
(
$
cassandraR
epository
,
$elasticRepository
,
$entitiesBuilder
,
$guidBuilder
);
$this
->
cassandraRepository
=
$cassandraR
epository
;
$this
->
elasticRepository
=
$elasticRepository
;
$this
->
entitiesBuilder
=
$entitiesBuilder
;
$this
->
guidBuilder
=
$guidBuilder
;
...
...
@@ -47,7 +47,7 @@ class ManagerSpec extends ObjectBehavior
public
function
it_should_return_a_list_of_boosts_to_review
()
{
$response
=
new
Response
([
$response
Obj
=
new
Response
([
(
new
Boost
)
->
setGuid
(
1
)
->
setEntityGuid
(
123
)
...
...
@@ -61,19 +61,19 @@ class ManagerSpec extends ObjectBehavior
]);
$this
->
elasticRepository
->
getList
([
'state'
=>
'review'
,
'state'
=>
Manager
::
OPT_STATEQUERY_REVIEW
,
'useElastic'
=>
true
,
])
->
shouldBeCalled
()
->
willReturn
(
$response
);
->
willReturn
(
$response
Obj
);
$this
->
r
epository
->
getList
([
'state'
=>
'review'
,
$this
->
cassandraR
epository
->
getList
([
'state'
=>
Manager
::
OPT_STATEQUERY_REVIEW
,
'useElastic'
=>
true
,
'guids'
=>
[
1
,
2
],
])
->
shouldBeCalled
()
->
willReturn
(
$response
);
->
willReturn
(
$response
Obj
);
$this
->
entitiesBuilder
->
single
(
123
)
->
shouldBeCalled
()
->
willReturn
((
new
Activity
)
->
set
(
'guid'
,
123
));
$this
->
entitiesBuilder
->
single
(
1
)
->
shouldBeCalled
()
->
willReturn
((
new
User
)
->
set
(
'guid'
,
1
));
...
...
@@ -81,7 +81,7 @@ class ManagerSpec extends ObjectBehavior
$this
->
entitiesBuilder
->
single
(
2
)
->
shouldBeCalled
()
->
willReturn
((
new
User
)
->
set
(
'guid'
,
2
));
$response
=
$this
->
getList
([
'state'
=>
'review'
,
'state'
=>
Manager
::
OPT_STATEQUERY_REVIEW
,
]);
$response
[
0
]
->
getEntity
()
->
getGuid
()
->
shouldBe
(
123
);
...
...
@@ -95,7 +95,7 @@ class ManagerSpec extends ObjectBehavior
public
function
it_should_return_a_list_of_boosts_to_deliver
()
{
$response
=
new
Response
([
$response
Obj
=
new
Response
([
(
new
Boost
)
->
setEntityGuid
(
123
)
->
setImpressions
(
1000
)
...
...
@@ -105,12 +105,11 @@ class ManagerSpec extends ObjectBehavior
->
setImpressions
(
100
)
->
setOwnerGuid
(
2
)
]);
$this
->
elasticRepository
->
getList
([
'state'
=>
'approved'
,
'state'
=>
Manager
::
OPT_STATEQUERY_APPROVED
,
'useElastic'
=>
true
,
])
->
shouldBeCalled
()
->
willReturn
(
$response
);
])
->
shouldBeCalled
()
->
willReturn
(
$responseObj
);
$this
->
entitiesBuilder
->
single
(
123
)
->
shouldBeCalled
()
->
willReturn
((
new
Activity
)
->
set
(
'guid'
,
123
));
$this
->
entitiesBuilder
->
single
(
1
)
->
shouldBeCalled
()
->
willReturn
((
new
User
)
->
set
(
'guid'
,
1
));
...
...
@@ -118,7 +117,7 @@ class ManagerSpec extends ObjectBehavior
$this
->
entitiesBuilder
->
single
(
2
)
->
shouldBeCalled
()
->
willReturn
((
new
User
)
->
set
(
'guid'
,
2
));
$response
=
$this
->
getList
([
'state'
=>
'approved'
,
'state'
=>
Manager
::
OPT_STATEQUERY_APPROVED
,
'useElastic'
=>
true
,
]);
...
...
@@ -144,7 +143,7 @@ class ManagerSpec extends ObjectBehavior
->
setOwnerGuid
(
2
)
]);
$this
->
r
epository
->
getList
([
$this
->
cassandraR
epository
->
getList
([
'state'
=>
null
,
'guids'
=>
[
123
,
456
],
'useElastic'
=>
false
,
...
...
@@ -177,7 +176,7 @@ class ManagerSpec extends ObjectBehavior
$boost
->
getGuid
()
->
shouldbeCalled
()
->
willReturn
(
null
);
$boost
->
setGuid
(
1
)
->
shouldBeCalled
();
$this
->
r
epository
->
add
(
$boost
)
->
shouldBeCalled
();
$this
->
cassandraR
epository
->
add
(
$boost
)
->
shouldBeCalled
();
$this
->
elasticRepository
->
add
(
$boost
)
->
shouldBeCalled
();
$this
->
add
(
$boost
)
->
shouldReturn
(
true
);
...
...
@@ -185,7 +184,7 @@ class ManagerSpec extends ObjectBehavior
public
function
it_should_update_a_boost
(
Boost
$boost
)
{
$this
->
r
epository
->
update
(
$boost
,
[
'@timestamp'
])
->
shouldBeCalled
();
$this
->
cassandraR
epository
->
update
(
$boost
,
[
'@timestamp'
])
->
shouldBeCalled
();
$this
->
elasticRepository
->
update
(
$boost
,
[
'@timestamp'
])
->
shouldBeCalled
();
$this
->
update
(
$boost
,
[
'@timestamp'
]);
...
...
@@ -210,7 +209,7 @@ class ManagerSpec extends ObjectBehavior
$this
->
elasticRepository
->
getList
(
$params
)
->
shouldBeCalled
()
->
willReturn
(
$response
);
$response
->
toArray
()
->
shouldbeCalled
()
->
willReturn
([
$boost
]);
$this
->
r
epository
->
getList
(
Argument
::
any
())
->
shouldBeCalled
()
->
willReturn
(
$response
);
$this
->
cassandraR
epository
->
getList
(
Argument
::
any
())
->
shouldBeCalled
()
->
willReturn
(
$response
);
$boost
->
getGuid
()
->
shouldBeCalled
()
->
willReturn
(
'9012'
);
$boost
->
getType
()
->
shouldBeCalled
()
->
willReturn
(
'newsfeed'
);
...
...
@@ -250,7 +249,7 @@ class ManagerSpec extends ObjectBehavior
];
$this
->
elasticRepository
->
getList
(
$params
)
->
shouldBeCalled
()
->
willReturn
(
$response
);
$response
->
toArray
()
->
shouldbeCalled
()
->
willReturn
([
$boost
]);
$this
->
r
epository
->
getList
(
Argument
::
any
())
->
shouldBeCalled
()
->
willReturn
(
$response
);
$this
->
cassandraR
epository
->
getList
(
Argument
::
any
())
->
shouldBeCalled
()
->
willReturn
(
$response
);
$boost
->
getGuid
()
->
shouldBeCalled
()
->
willReturn
(
'9012'
);
$boost
->
getEntityGuid
()
->
shouldBeCalled
()
->
willReturn
(
'1234'
);
...
...
@@ -350,7 +349,7 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
new
Response
(
$existingBoosts
,
''
));
$this
->
r
epository
->
getList
(
Argument
::
any
())
$this
->
cassandraR
epository
->
getList
(
Argument
::
any
())
->
shouldBeCalled
()
->
willReturn
(
new
Response
(
$existingBoosts
));
...
...
This diff is collapsed.