Skip to content
Commits on Source (2)
......@@ -130,7 +130,17 @@ class Iterator implements \Iterator
public function getList()
{
$response = $this->manager->getList(['limit' => $this->limit, 'from' => $this->from, 'offset' => $this->offset, 'type' => $this->type, 'owner_guid' => $this->ownerGuid, 'state' => $this->state, 'rating' => $this->rating, 'quality' => $this->quality,]);
$response = $this->manager->getList([
'limit' => $this->limit,
'from' => $this->from,
'offset' => $this->offset,
'type' => $this->type,
'owner_guid' => $this->ownerGuid,
'state' => $this->state,
'rating' => $this->rating,
'quality' => $this->quality,
]);
$this->offset = $response->getPagingToken();
$this->list = $response;
}
......
......@@ -73,17 +73,19 @@ class Metrics
// NOTE: Campaigns have a _single_ entity, for now. Refactor this when we support multiple
// Ideally, we should use a composite URN, like: urn:campaign-entity:100000321:(urn:activity:100000500)
foreach ($this->campaign->getEntityUrns() as $entityUrn) {
$entity = $this->resolver->setOpts(['ignoreAcl' => true])->single(new Urn($entityUrn));
$this->counters
->setEntityGuid($entity->guid)
->setMetric('impression')
->increment();
$this->counters
->setEntityGuid($entity->owner_guid)
->setMetric('impression')
->increment();
$entity = $this->resolver->single(new Urn($entityUrn));
if ($entity) {
$this->counters
->setEntityGuid($entity->guid)
->setMetric('impression')
->increment();
$this->counters
->setEntityGuid($entity->owner_guid)
->setMetric('impression')
->increment();
}
}
return true;
......
......@@ -83,27 +83,27 @@ class Repository
->setOwnerGuid($row['owner_guid']->toInt())
->setType($row['type']);
$data = json_decode($row['json_data'] ?: '{}', true);
$json_data = json_decode($row['json_data'] ?: '{}', true);
$campaign
->setName($data['name'])
->setEntityUrns(Text::buildArray($data['entity_urns']))
->setHashtags(Text::buildArray($data['hashtags']))
->setNsfw(Number::buildIntArray($data['nsfw']))
->setStart((int) $data['start'])
->setEnd((int) $data['end'])
->setBudget((string) $data['budget'])
->setBudgetType($data['budget_type'])
->setChecksum($data['checksum'])
->setImpressions((int) $data['impressions'])
->setImpressionsMet($data['impressions_met'])
->setRating($data['rating'])
->setQuality($data['quality'])
->setCreatedTimestamp(((int) $data['created_timestamp']) ?: null)
->setReviewedTimestamp(((int) $data['reviewed_timestamp']) ?: null)
->setRejectedTimestamp(((int) $data['rejected_timestamp']) ?: null)
->setRevokedTimestamp(((int) $data['revoked_timestamp']) ?: null)
->setCompletedTimestamp(((int) $data['completed_timestamp']) ?: null);
->setName($json_data['name'])
->setEntityUrns(Text::buildArray($json_data['entity_urns']))
->setHashtags(Text::buildArray($json_data['hashtags']))
->setNsfw(Number::buildIntArray($json_data['nsfw']))
->setStart((int) $json_data['start'])
->setEnd((int) $json_data['end'])
->setBudget((string) $json_data['budget'])
->setBudgetType($json_data['budget_type'])
->setChecksum($json_data['checksum'])
->setImpressions((int) $json_data['impressions'])
->setImpressionsMet($json_data['impressions_met'])
->setRating($json_data['rating'])
->setQuality($json_data['quality'])
->setCreatedTimestamp(((int) $json_data['created_timestamp']) ?: null)
->setReviewedTimestamp(((int) $json_data['reviewed_timestamp']) ?: null)
->setRejectedTimestamp(((int) $json_data['rejected_timestamp']) ?: null)
->setRevokedTimestamp(((int) $json_data['revoked_timestamp']) ?: null)
->setCompletedTimestamp(((int) $json_data['completed_timestamp']) ?: null);
$response[] = $campaign;
}
......@@ -126,33 +126,36 @@ class Repository
public function add(Campaign $campaign, $async = true)
{
$cql = "INSERT INTO boost_campaigns (type, guid, owner_guid, json_data, delivery_status) VALUES (?, ?, ?, ?, ?)";
$json_data = [
'urn' => $campaign->getUrn(),
'owner_guid' => (string) $campaign->getOwnerGuid(),
'name' => $campaign->getName(),
'type' => $campaign->getType(),
'entity_urns' => $campaign->getEntityUrns(),
'hashtags' => $campaign->getHashtags(),
'nsfw' => $campaign->getNsfw(),
'start' => $campaign->getStart(),
'end' => $campaign->getEnd(),
'budget' => $campaign->getBudget(),
'budget_type' => $campaign->getBudgetType(),
'checksum' => $campaign->getChecksum(),
'impressions' => $campaign->getImpressions(),
'impressions_met' => $campaign->getImpressionsMet(),
'rating' => $campaign->getRating(),
'quality' => $campaign->getQuality(),
'created_timestamp' => $campaign->getCreatedTimestamp(),
'reviewed_timestamp' => $campaign->getReviewedTimestamp(),
'rejected_timestamp' => $campaign->getRejectedTimestamp(),
'revoked_timestamp' => $campaign->getRevokedTimestamp(),
'completed_timestamp' => $campaign->getCompletedTimestamp(),
];
$values = [
$campaign->getType(),
new Bigint($campaign->getGuid()),
new Bigint($campaign->getOwnerGuid()),
json_encode([
'urn' => $campaign->getUrn(),
'owner_guid' => (string) $campaign->getOwnerGuid(),
'name' => $campaign->getName(),
'type' => $campaign->getType(),
'entity_urns' => $campaign->getEntityUrns(),
'hashtags' => $campaign->getHashtags(),
'nsfw' => $campaign->getNsfw(),
'start' => $campaign->getStart(),
'end' => $campaign->getEnd(),
'budget' => $campaign->getBudget(),
'budget_type' => $campaign->getBudgetType(),
'checksum' => $campaign->getChecksum(),
'impressions' => $campaign->getImpressions(),
'impressions_met' => $campaign->getImpressionsMet(),
'rating' => $campaign->getRating(),
'quality' => $campaign->getQuality(),
'created_timestamp' => $campaign->getCreatedTimestamp(),
'reviewed_timestamp' => $campaign->getReviewedTimestamp(),
'rejected_timestamp' => $campaign->getRejectedTimestamp(),
'revoked_timestamp' => $campaign->getRevokedTimestamp(),
'completed_timestamp' => $campaign->getCompletedTimestamp(),
]),
json_encode($json_data),
$campaign->getDeliveryStatus(),
];
......
......@@ -79,11 +79,14 @@ class BoostCampaignResolverDelegate implements ResolverDelegate
return null;
}
$entity = $this->resolver->setOpts(['ignoreAcl' => true])->single(new Urn($campaign->getEntityUrns()[0]));
$entity->boosted = true;
$entity->boosted_guid = $campaign->getUrn();
$entity->boosted_onchain = true;
$entity->urn = $campaign->getUrn();
$entity = $this->resolver->single(new Urn($campaign->getEntityUrns()[0]));
if ($entity) {
$entity->boosted = true;
$entity->boosted_guid = $campaign->getUrn();
$entity->boosted_onchain = true;
$entity->urn = $campaign->getUrn();
}
return $entity;
}
......
......@@ -131,16 +131,12 @@ class Resolver
$sorted = array_filter($sorted, function ($entity) { return (bool) $entity; });
// Filter out forbidden entities, if not ignoring ACL
// Filter out forbidden entities
$ignoreAcl = $this->opts['ignoreAcl'] ?? false;
if (!$ignoreAcl) {
$sorted = array_filter($sorted, function($entity) {
return $this->acl->read($entity, $this->user);
//&& !Flags::shouldFail($entity);
});
}
$sorted = array_filter($sorted, function($entity) {
return $this->acl->read($entity, $this->user);
//&& !Flags::shouldFail($entity);
});
//
......