Commit a2c75e45 authored by Mark Harding's avatar Mark Harding

(feat): store activity owner_guid for all views - closes #822

parent 61f0bd82
No related merge requests found
Pipeline #82432296 passed with stages
in 11 minutes and 16 seconds
......@@ -105,6 +105,7 @@ class views implements Interfaces\Api
$viewsManager->record(
(new Core\Analytics\Views\View())
->setEntityUrn($activity->getUrn())
->setOwnerGuid((string) $activity->getOwnerGuid())
->setClientMeta($_POST['client_meta'] ?? [])
);
} catch (\Exception $e) {
......
......@@ -55,6 +55,7 @@ class ElasticRepository
'uuid' => $view->getUuid(),
'@timestamp' => $view->getTimestamp() * 1000,
'entity_urn' => $view->getEntityUrn(),
'owner_guid' => $view->getOwnerGuid(),
'page_token' => $view->getPageToken(),
'campaign' => $view->getCampaign(),
'delta' => (int) $view->getDelta(),
......
......@@ -104,6 +104,7 @@ class Repository
->setDay((int) $row['day'] ?: null)
->setUuid($row['uuid']->uuid() ?: null)
->setEntityUrn($row['entity_urn'])
->setOwnerGuid($row['owner_guid'])
->setPageToken($row['page_token'])
->setPosition((int) $row['position'])
->setSource($row['platform'])
......@@ -135,13 +136,14 @@ class Repository
$timestamp = $view->getTimestamp() ?: time();
$date = new DateTime("@{$timestamp}", new DateTimeZone('utc'));
$cql = "INSERT INTO views (year, month, day, uuid, entity_urn, page_token, position, platform, source, medium, campaign, delta) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$cql = "INSERT INTO views (year, month, day, uuid, entity_urn, owner_guid, page_token, position, platform, source, medium, campaign, delta) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$values = [
(int) ($view->getYear() ?? $date->format('Y')),
new Tinyint((int) ($view->getMonth() ?? $date->format('m'))),
new Tinyint((int) ($view->getDay() ?? $date->format('d'))),
new Timeuuid($view->getUuid() ?? $timestamp * 1000),
$view->getEntityUrn() ?: '',
(string) ($view->getOwnerGuid() ?? ''),
$view->getPageToken() ?: '',
(int) ($view->getPosition() ?? -1),
$view->getPlatform() ?: '',
......
......@@ -21,6 +21,8 @@ use Minds\Traits\MagicAttributes;
* @method string getUuid()
* @method View setEntityUrn(string $entityUrn)
* @method string getEntityUrn()
* @method View setOwnerGuid(string $ownerGuid)
* @method string getOwnerGuid()
* @method View setPageToken(string $pageToken)
* @method string getPageToken()
* @method View setPosition(int $position)
......@@ -57,6 +59,9 @@ class View
/** @var string */
protected $entityUrn;
/** @var string */
protected $ownerGuid;
/** @var string */
protected $pageToken;
......
......@@ -1445,3 +1445,5 @@ CREATE TABLE minds.email_campaign_logs (
email_campaign_id text,
PRIMARY KEY (receiver_guid, time_sent)
) WITH CLUSTERING ORDER BY (time_sent desc);
ALTER TABLE minds.views ADD owner_guid text;
\ No newline at end of file
......@@ -61,6 +61,10 @@ class RepositorySpec extends ObjectBehavior
->shouldBeCalled()
->willReturn('urn:test:123123');
$view->getOwnerGuid()
->shouldBeCalled()
->wilLReturn('789');
$view->getPageToken()
->shouldBeCalled()
->willReturn('1234-qwe-qwe-1234');
......@@ -98,13 +102,14 @@ class RepositorySpec extends ObjectBehavior
$statement['values'][2]->toInt() === 29 &&
$statement['values'][3]->uuid() === 'abc-123-456-def' &&
$statement['values'][4] === 'urn:test:123123' &&
$statement['values'][5] === '1234-qwe-qwe-1234' &&
$statement['values'][6] === 5 &&
$statement['values'][7] === 'php' &&
$statement['values'][8] === 'phpspec' &&
$statement['values'][9] === 'test' &&
$statement['values'][10] === 'urn:phpspec:234234' &&
$statement['values'][11] === 100;
$statement['values'][5] === '789' &&
$statement['values'][6] === '1234-qwe-qwe-1234' &&
$statement['values'][7] === 5 &&
$statement['values'][8] === 'php' &&
$statement['values'][9] === 'phpspec' &&
$statement['values'][10] === 'test' &&
$statement['values'][11] === 'urn:phpspec:234234' &&
$statement['values'][12] === 100;
}), true)
->shouldBeCalled()
->willReturn(true);
......@@ -143,6 +148,10 @@ class RepositorySpec extends ObjectBehavior
->shouldBeCalled()
->willReturn('urn:test:123123');
$view->getOwnerGuid()
->shouldBeCalled()
->willReturn(789);
$view->getPageToken()
->shouldBeCalled()
->willReturn('1234-qwe-qwe-1234');
......@@ -180,13 +189,14 @@ class RepositorySpec extends ObjectBehavior
$statement['values'][2]->toInt() === 29 &&
$statement['values'][3]->time() === $now * 1000 &&
$statement['values'][4] === 'urn:test:123123' &&
$statement['values'][5] === '1234-qwe-qwe-1234' &&
$statement['values'][6] === 5 &&
$statement['values'][7] === 'php' &&
$statement['values'][8] === 'phpspec' &&
$statement['values'][9] === 'test' &&
$statement['values'][10] === 'urn:phpspec:234234' &&
$statement['values'][11] === 100;
$statement['values'][5] === '789' &&
$statement['values'][6] === '1234-qwe-qwe-1234' &&
$statement['values'][7] === 5 &&
$statement['values'][8] === 'php' &&
$statement['values'][9] === 'phpspec' &&
$statement['values'][10] === 'test' &&
$statement['values'][11] === 'urn:phpspec:234234' &&
$statement['values'][12] === 100;
}), true)
->shouldBeCalled()
->willReturn(true);
......
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