Skip to content

Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
Minds Backend - Engine
Minds Backend - Engine
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 155
    • Issues 155
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 41
    • Merge Requests 41
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Registry
    • Registry
  • Packages
    • Packages
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Minds
  • Minds Backend - EngineMinds Backend - Engine
  • Merge Requests
  • !210

Open
Opened 2 hours ago by Olivia Madrid@omadrid
  • Report abuse
Report abuse

WIP: epic/Referrals

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch https://gitlab.com/omadrid/engine.git epic/Referrals
git checkout -b omadrid/engine-epic/Referrals FETCH_HEAD

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout origin/master
git merge --no-ff omadrid/engine-epic/Referrals

Step 4. Push the result of the merge to GitLab

git push origin master

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

Request to merge omadrid:epic/Referrals into master
The source branch is 1 commit behind the target branch
Open in Web IDE
  • Email patches
  • Plain diff
Pipeline #66606615 (#10) failed for 9f11fc4c on omadrid:epic/Referrals
      Requires 2 more approvals from Devs.
      Marcelo Rivera
      Marcelo Rivera
      Emiliano Balbuena
      Emiliano Balbuena
      Ben Hayward
      Ben Hayward
      Martin Santangelo
      Martin Santangelo
      Mark Harding
      Mark Harding
      This is a Work in Progress
      You can merge this merge request manually using the
      • Discussion 10
      • Commits 2
      • Pipelines 1
      • Changes 12
      0/10 discussions resolved
      • Loading...
      • Mark Harding
        Mark Harding @markeharding started a discussion on the diff 1 hour ago
        Core/Rewards/Join.php
        181 182 ->setEntityType('user')
        182 183 ->setAction('referral')
        183 184 ->push();
        185
        186
        187 $referral = new Referral();
        • Mark Harding
          Mark Harding @markeharding · 1 hour ago
          Owner

          Can we make this a delegate? ie. -> Core/Rewards/Join/Delegates/ReferralDelegate

        Please register or sign in to reply
      • Mark Harding
        Mark Harding @markeharding started a discussion on the diff 1 hour ago
        Core/Referrals/Repository.php
        104 }
        105
        106 return $success;
        107 }
        108
        109 /**
        110 * Update a referral
        111 * @param Referral $referral
        112 * @return bool
        113 */
        114 public function update(Referral $referral)
        115 {
        116 // incoming $referral will have prospectGuid and joinTimestamp
        117
        118 // OJMTODO: check - shouldn't need IF EXISTS because referralValidator
        119 $template = "UPDATE referrals SET join_timestamp = ? WHERE prospect_guid = ?";
        • Mark Harding
          Mark Harding @markeharding · 1 hour ago
          Owner

          should not be necessary as cassandra will upsert

        Please register or sign in to reply
      • Mark Harding
        Mark Harding @markeharding started a discussion on the diff 1 hour ago
        Core/Referrals/Repository.php
        57 $response = $e;
        58 return $response;
        59 }
        60
        61 return $response;
        62 }
        63
        64
        65 /**
        66 * Add a referral
        67 * @param Referral $referral
        68 * @return bool
        69 */
        70 public function add(Referral $referral)
        71 {
        72 // OJMQ: are these validation checks necessary?
        • Mark Harding
          Mark Harding @markeharding · 1 hour ago
          Owner

          yes I think so

        Please register or sign in to reply
      • Mark Harding
        Mark Harding @markeharding started a discussion on the diff 1 hour ago
        Core/Referrals/Manager.php
        14
        15 public function __construct(
        16 $repository = null
        17 )
        18 {
        19 $this->repository = $repository ?: new Repository;
        20 }
        21
        22 /**
        23 * Create referral for registered prospect
        24 * @param ReferrerGuid $referrerGuid
        25 * @return bool
        26 */
        27 public function add($referral)
        28 {
        29 // OJMQ: what happens if the add() fails?
        • Mark Harding
          Mark Harding @markeharding · 1 hour ago
          Owner

          I would return the value of repository add to solve

        Please register or sign in to reply
      • Mark Harding
        Mark Harding @markeharding started a discussion on the diff 1 hour ago
        Core/Provisioner/Provisioners/cassandra-provision.cql
        1394 1394 delta int,
        1395 1395 PRIMARY KEY (year, month, day, uuid, entity_urn, page_token)
        1396 1396 );
        1397
        1398
        1399 -- CREATE TABLE minds.referrals (
        1400 -- prospect_guid varint,
        1401 -- referrer_guid varint,
        1402 -- register_timestamp timestamp,
        1403 -- join_timestamp timestamp,
        1404 -- PRIMARY KEY (prospect_guid)
        • Mark Harding
          Mark Harding @markeharding · 1 hour ago
          Owner

          recommend PRIMARY KEY (referrer_guid, prospect_guid)

        Please register or sign in to reply
      • Mark Harding
        Mark Harding @markeharding started a discussion on the diff 1 hour ago
        Core/Events/Hooks/Register.php
        36 38 $params['user']->save();
        37 39 $params['user']->subscribe($user->guid);
        38 40 }
        41
        42 // OJMQ: should I put a null value for joinTimestamp here?
        43 $referral = new Referral();
        44 $referral->setProspectGuid(Core\Session::getLoggedInUserGuid())
        45 ->setReferrerGuid((string) $user->guid)
        46 ->setRegisterTimestamp(time());
        47
        48 $manager = Di::_()->get('Referrals\Manager');
        49 $manager->add($referral);
        50 // OJMTODO: make sure it happens? do something if return(!true)?
        • Mark Harding
          Mark Harding @markeharding · 1 hour ago
          Owner

          I don't think a response is needed, registration should prevail.

        Please register or sign in to reply
      • Mark Harding
        Mark Harding @markeharding started a discussion on the diff 1 hour ago
        Core/Events/Hooks/Register.php
        36 38 $params['user']->save();
        37 39 $params['user']->subscribe($user->guid);
        38 40 }
        41
        42 // OJMQ: should I put a null value for joinTimestamp here?
        • Mark Harding
          Mark Harding @markeharding · 1 hour ago
          Owner

          time() is fine

        Please register or sign in to reply
      • Mark Harding
        Mark Harding @markeharding started a discussion on the diff 1 hour ago
        Core/Events/Hooks/Register.php
        36 38 $params['user']->save();
        37 39 $params['user']->subscribe($user->guid);
        38 40 }
        41
        42 // OJMQ: should I put a null value for joinTimestamp here?
        43 $referral = new Referral();
        44 $referral->setProspectGuid(Core\Session::getLoggedInUserGuid())
        • Mark Harding
          Mark Harding @markeharding · 1 hour ago
          Owner

          Don't assume current session when outside of Controllers. $params['user'] is passed and a user entity, so we cant take from there

        Please register or sign in to reply
      • Mark Harding
        Mark Harding @markeharding started a discussion on the diff 1 hour ago
        Controllers/api/v2/referrals.php
        26 $referral = new Referral();
        27 $referral->setReferrerGuid(Core\Session::getLoggedInUserGuid());
        28
        29 $manager = Di::_()->get('Referrals\Manager');
        30 $referrals = $manager->getList($referral);
        31
        32 // OJMTODO: confirm what is the outcome for request with no referrals
        33 // OJMTODO: incorporate no referral case into UI
        34 if (!$referrals) {
        35 return Factory::response(array(
        36 'status' => 'error',
        37 'message' => 'You have no referrals'
        38 ));
        39 }
        40
        41 // OJMQ: hydrate here? or frontend as needed?
        • Mark Harding
          Mark Harding @markeharding · 1 hour ago
          Owner

          Manager should manager hydration.

        Please register or sign in to reply
      • Mark Harding
        Mark Harding @markeharding started a discussion on the diff 1 hour ago
        Controllers/api/v1/register.php
        97 97 'guid' => $guid,
        98 98 'user' => $user->export()
        99 99 ];
        100
        101 // OJMTODO: if the response is successful AND isset($_COOKIE['referrer'])
        • Mark Harding
          Mark Harding @markeharding · 1 hour ago
          Owner

          I don't think anything is needed here as the events are picking up

        Please register or sign in to reply
      • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
      Please register or sign in to reply
      Assignee
      None
      Assign to
      None
      Milestone
      None
      Assign milestone
      None
      Time tracking
      No estimate or time spent
      0
      Labels
      None
      Assign labels
      • View project labels
      Lock merge request
      Unlocked
      8
      8 participants
      user avatar
      Marcelo Rivera
      user avatar
      Emiliano Balbuena
      user avatar
      Ben Hayward
      user avatar
      Martin Santangelo
      user avatar
      Mark Harding
      user avatar
      Rami Albatal
      user avatar
      Brian Hatchet
      Reference: minds/engine!210