Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
185
Issues
185
List
Boards
Labels
Service Desk
Milestones
Merge Requests
33
Merge Requests
33
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
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
f1f564ceffc53a22143eddde6c8ef92789be452b...837dbad65cabe648c232e137d90aea5d04c7759f
Source
837dbad65cabe648c232e137d90aea5d04c7759f
Select Git revision
...
Target
f1f564ceffc53a22143eddde6c8ef92789be452b
Select Git revision
Compare
Commits (2)
(feat): save impressions_met to ES every 10 views
· 03deb56d
Marcelo Rivera
authored
3 hours ago
03deb56d
(feat): implement type filtering
· 837dbad6
Marcelo Rivera
authored
2 hours ago
837dbad6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
7 deletions
+24
-7
Dispatcher.php
Core/Boost/Campaigns/Dispatcher.php
+7
-3
ElasticRepository.php
Core/Boost/Campaigns/ElasticRepository.php
+17
-4
No files found.
Core/Boost/Campaigns/Dispatcher.php
View file @
837dbad6
...
...
@@ -10,6 +10,8 @@ use Exception;
class
Dispatcher
{
const
SAVE_DELTA
=
10
;
/** @var Manager */
protected
$manager
;
...
...
@@ -43,13 +45,15 @@ class Dispatcher
$campaign
=
$this
->
manager
->
get
(
$campaignRef
->
getUrn
());
if
(
$campaign
->
isDelivering
())
{
$impressionsMet
=
$campaign
->
getImpressionsMet
();
$campaign
=
$this
->
metrics
->
setCampaign
(
$campaign
)
->
syncImpressionsMet
();
// TODO: Save campaign every 10/20 impressions to avoid ES overloading
error_log
(
"[BoostCampaignsDispatcher] Saving updated
{
$campaign
->
getUrn
()
}
..."
);
$this
->
manager
->
sync
(
$campaign
);
if
(
$campaign
->
getImpressionsMet
()
-
$impressionsMet
>=
static
::
SAVE_DELTA
)
{
error_log
(
"[BoostCampaignsDispatcher] Saving updated
{
$campaign
->
getUrn
()
}
..."
);
$this
->
manager
->
sync
(
$campaign
);
}
}
if
(
$campaign
->
shouldBeCompleted
(
$now
))
{
...
...
This diff is collapsed.
Click to expand it.
Core/Boost/Campaigns/ElasticRepository.php
View file @
837dbad6
...
...
@@ -58,7 +58,7 @@ class ElasticRepository
$must_not
=
[];
$sort
=
[
'@timestamp'
=>
$opts
[
'sort'
]
'@timestamp'
=>
$opts
[
'sort'
]
,
];
//
...
...
@@ -88,8 +88,8 @@ class ElasticRepository
if
(
$opts
[
'entity_urn'
])
{
$must
[]
=
[
'term'
=>
[
'entity_urn'
=>
$opts
[
'entity_urn'
]
]
'entity_urn'
=>
$opts
[
'entity_urn'
]
,
]
,
];
}
...
...
@@ -232,6 +232,7 @@ class ElasticRepository
'sort'
=>
'asc'
,
],
$opts
);
$filter
=
[];
$must
=
[];
if
(
$opts
[
'offset'
])
{
...
...
@@ -246,15 +247,24 @@ class ElasticRepository
];
}
if
(
$opts
[
'type'
])
{
$filter
[]
=
[
'term'
=>
[
'type'
=>
$opts
[
'type'
],
],
];
}
$sort
=
[
'@timestamp'
=>
$opts
[
'sort'
]
??
'asc'
];
$body
=
[
'query'
=>
[
'bool'
=>
[
'filter'
=>
$filter
,
'must'
=>
$must
,
],
],
'sort'
=>
$sort
'sort'
=>
$sort
,
];
$prepared
=
new
Search
();
...
...
@@ -268,6 +278,9 @@ class ElasticRepository
$result
=
$this
->
es
->
request
(
$prepared
);
var_dump
(
$result
);
die
();
$data
=
[];
foreach
(
$result
[
'hits'
][
'hits'
]
as
$doc
)
{
...
...
This diff is collapsed.
Click to expand it.