Commit a2c75e45 authored by Mark Harding's avatar Mark Harding
Browse files

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

parent 61f0bd82
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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) {
+1 −0
Original line number Diff line number Diff line
@@ -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(),
+3 −1
Original line number Diff line number Diff line
@@ -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() ?: '',
+5 −0
Original line number Diff line number Diff line
@@ -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;

+2 −0
Original line number Diff line number Diff line
@@ -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
Loading