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
186
Issues
186
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
Commits
09997460
Commit
09997460
authored
3 minutes ago
by
Emiliano Balbuena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(fix): Synchronous queue save; update impression on revoke
parent
866a01b0
goal/boost-campaigns-e24
1 merge request
!235
WIP: Boost Campaigns (&24)
Pipeline
#73585750
running with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
19 deletions
+29
-19
Manager.php
Core/Boost/Campaigns/Manager.php
+22
-12
Repository.php
Core/Boost/Campaigns/Repository.php
+7
-7
No files found.
Core/Boost/Campaigns/Manager.php
View file @
09997460
...
...
@@ -23,6 +23,9 @@ class Manager
/** @var ElasticRepository */
protected
$elasticRepository
;
/** @var Metrics */
protected
$metrics
;
/** @var PaymentsRepository */
protected
$paymentsRepository
;
...
...
@@ -51,8 +54,9 @@ class Manager
* Manager constructor.
* @param Repository $repository
* @param ElasticRepository $elasticRepository
* @param Metrics $metrics
* @param PaymentsRepository $paymentsRepository
* @param
null
$queueClient
* @param
QueueClientInterface
$queueClient
* @param Delegates\CampaignUrnDelegate $campaignUrnDelegate
* @param Delegates\NormalizeDatesDelegate $normalizeDatesDelegate
* @param Delegates\NormalizeEntityUrnsDelegate $normalizeEntityUrnsDelegate
...
...
@@ -63,6 +67,7 @@ class Manager
public
function
__construct
(
$repository
=
null
,
$elasticRepository
=
null
,
$metrics
=
null
,
$paymentsRepository
=
null
,
$queueClient
=
null
,
$campaignUrnDelegate
=
null
,
...
...
@@ -74,6 +79,7 @@ class Manager
{
$this
->
repository
=
$repository
?:
new
Repository
();
$this
->
elasticRepository
=
$elasticRepository
?:
new
ElasticRepository
();
$this
->
metrics
=
$metrics
?:
new
Metrics
();
$this
->
paymentsRepository
=
$paymentsRepository
?:
new
PaymentsRepository
();
$this
->
queueClient
=
$queueClient
?:
QueueClient
::
build
();
...
...
@@ -99,6 +105,7 @@ class Manager
/**
* @param array $opts
* @return Response
* @throws Exception
*/
public
function
getList
(
array
$opts
=
[])
{
...
...
@@ -146,6 +153,7 @@ class Manager
/**
* @param $urn
* @param array $opts
* @return Campaign|null
* @throws Exception
*/
...
...
@@ -241,6 +249,7 @@ class Manager
* @param mixed $paymentPayload
* @return Campaign
* @throws CampaignException
* @throws Exception
*/
public
function
update
(
Campaign
$campaignRef
,
$paymentPayload
=
null
)
{
...
...
@@ -286,8 +295,7 @@ class Manager
// Write
$this
->
repository
->
update
(
$campaign
);
$this
->
elasticRepository
->
update
(
$campaign
);
$this
->
sync
(
$campaign
);
// Queue for lifecycle events
...
...
@@ -309,7 +317,7 @@ class Manager
*/
public
function
sync
(
Campaign
$campaign
)
{
$this
->
repository
->
update
(
$campaign
);
$this
->
repository
->
update
(
$campaign
,
true
);
$this
->
elasticRepository
->
update
(
$campaign
);
return
$campaign
;
...
...
@@ -362,8 +370,7 @@ class Manager
// Write
$this
->
repository
->
update
(
$campaign
);
$this
->
elasticRepository
->
update
(
$campaign
);
$this
->
sync
(
$campaign
);
//
...
...
@@ -398,6 +405,12 @@ class Manager
throw
new
CampaignException
(
'Campaign should be in [created] or [approved] state in order to cancel it'
);
}
// Sync impressions
$campaign
=
$this
->
metrics
->
setCampaign
(
$campaign
)
->
syncImpressionsMet
();
// Update
$campaign
...
...
@@ -409,8 +422,7 @@ class Manager
// Write
$this
->
repository
->
update
(
$campaign
);
$this
->
elasticRepository
->
update
(
$campaign
);
$this
->
sync
(
$campaign
);
//
...
...
@@ -454,8 +466,7 @@ class Manager
// Write
$this
->
repository
->
update
(
$campaign
);
$this
->
elasticRepository
->
update
(
$campaign
);
$this
->
sync
(
$campaign
);
//
...
...
@@ -499,8 +510,7 @@ class Manager
// Write
$this
->
repository
->
update
(
$campaign
);
$this
->
elasticRepository
->
update
(
$campaign
);
$this
->
sync
(
$campaign
);
return
$campaign
;
}
...
...
This diff is collapsed.
Click to expand it.
Core/Boost/Campaigns/Repository.php
View file @
09997460
...
...
@@ -99,7 +99,7 @@ class Repository
->
setImpressionsMet
(
$data
[
'impressions_met'
])
->
setRating
(
$data
[
'rating'
])
->
setQuality
(
$data
[
'quality'
])
->
setCreatedTimestamp
(((
int
)
$data
[
'
timestamp
_timestamp'
])
?:
null
)
->
setCreatedTimestamp
(((
int
)
$data
[
'
created
_timestamp'
])
?:
null
)
->
setReviewedTimestamp
(((
int
)
$data
[
'reviewed_timestamp'
])
?:
null
)
->
setRejectedTimestamp
(((
int
)
$data
[
'rejected_timestamp'
])
?:
null
)
->
setRevokedTimestamp
(((
int
)
$data
[
'revoked_timestamp'
])
?:
null
)
...
...
@@ -120,10 +120,10 @@ class Repository
/**
* @param Campaign $campaign
* @param bool $async
* @return bool
* @throws Exception
*/
public
function
add
(
Campaign
$campaign
)
public
function
add
(
Campaign
$campaign
,
$async
=
true
)
{
$cql
=
"INSERT INTO boost_campaigns (type, guid, owner_guid, json_data, delivery_status) VALUES (?, ?, ?, ?, ?)"
;
$values
=
[
...
...
@@ -159,17 +159,17 @@ class Repository
$prepared
=
new
Custom
();
$prepared
->
query
(
$cql
,
$values
);
return
(
bool
)
$this
->
db
->
request
(
$prepared
,
true
);
return
(
bool
)
$this
->
db
->
request
(
$prepared
,
$async
);
}
/**
* @param Campaign $campaign
* @param bool $async
* @return bool
* @throws Exception
*/
public
function
update
(
Campaign
$campaign
)
public
function
update
(
Campaign
$campaign
,
$async
=
true
)
{
return
$this
->
add
(
$campaign
);
return
$this
->
add
(
$campaign
,
$async
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment