Commit 1f852b07 authored by Emiliano Balbuena's avatar Emiliano Balbuena

(chore): Use decimal for payments; impressions threshold

1 merge request!235WIP: Boost Campaigns (&24)
Pipeline #73571829 passed with stages
in 9 minutes and 4 seconds
......@@ -10,7 +10,7 @@ use Exception;
class Dispatcher
{
const SAVE_DELTA = 10;
const IMPRESSIONS_SYNC_THRESHOLD = 1;
/** @var Manager */
protected $manager;
......@@ -18,19 +18,25 @@ class Dispatcher
/** @var Metrics */
protected $metrics;
/** @var int */
protected $impressionsSyncThreshold;
/**
* Dispatcher constructor.
* @param Manager $manager
* @param Metrics $metrics
* @param int $impressionsSyncThreshold
* @throws Exception
*/
public function __construct(
$manager = null,
$metrics = null
$metrics = null,
$impressionsSyncThreshold = null
)
{
$this->manager = $manager ?: new Manager();
$this->metrics = $metrics ?: new Metrics();
$this->impressionsSyncThreshold = $impressionsSyncThreshold ?: static::IMPRESSIONS_SYNC_THRESHOLD;
}
/**
......@@ -50,7 +56,7 @@ class Dispatcher
->setCampaign($campaign)
->syncImpressionsMet();
if ($campaign->getImpressionsMet() - $impressionsMet >= static::SAVE_DELTA) {
if ($campaign->getImpressionsMet() - $impressionsMet >= $this->impressionsSyncThreshold) {
error_log("[BoostCampaignsDispatcher] Saving updated {$campaign->getUrn()}...");
$this->manager->sync($campaign);
}
......
......@@ -1467,7 +1467,7 @@ CREATE TABLE minds.boost_campaigns_payments (
campaign_guid bigint,
tx text,
source text,
amount varint,
amount decimal,
time_created timestamp,
PRIMARY KEY (owner_guid, campaign_guid, tx)
) WITH CLUSTERING ORDER BY (campaign_guid ASC, tx ASC);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment