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
    • Dependency List
    • Cycle Analytics
    • Insights
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 173
    • Issues 173
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 43
    • Merge Requests 43
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Packages
    • Packages
    • List
    • Container Registry
  • 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
  • !279

Open
Opened 3 days ago by Ben Hayward@benhayward.ben
  • Report abuse
Report abuse

[Sprint/JollyJellyfish](feat): Added plus tiers to endpoint and passed through #578

Edited 19 hours ago by Ben Hayward

Check out, review, and merge locally

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

git fetch origin
git checkout -b feat/plus-tiers-578 origin/feat/plus-tiers-578

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 feat/plus-tiers-578

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 feat/plus-tiers-578 into master
The source branch is 7 commits behind the target branch
Open in Web IDE
  • Email patches
  • Plain diff
Pipeline #72129790 passed for 5f801ecc on feat/plus-tiers-578
          Requires 2 more approvals from Devs and Deployers.
          Brian Hatchet
          Brian Hatchet
          Emiliano Balbuena
          Emiliano Balbuena
          Rami Albatal
          Rami Albatal
          Mark Harding
          Mark Harding
          Martin Santangelo
          Martin Santangelo
          Ready to be merged automatically. Ask someone with write access to this repository to merge this request

          Mentions #578

          Deletes source branch

          • Discussion 5
          • Commits 4
          • Pipelines 4
          • Changes 4
          0/5 threads resolved
          • Loading...
          • Ben Hayward @benhayward.ben added 1 commit 23 hours ago

            added 1 commit

            • 8ec1fcb2 - Updated to add spec tests

            Compare with previous version

          • Ben Hayward @benhayward.ben added 1 commit 23 hours ago

            added 1 commit

            • 4bbbf6eb - formatting

            Compare with previous version

          • Ben Hayward @benhayward.ben added 1 commit 19 hours ago

            added 1 commit

            • 5f801ecc - test update

            Compare with previous version

          • Ben Hayward @benhayward.ben unmarked as a Work In Progress 19 hours ago

            unmarked as a Work In Progress

          • Brian Hatchet
            Brian Hatchet :speech_balloon: @brianhatchet started a thread on the diff 34 minutes ago
            Spec/Core/Wire/Delegates/PlusSpec.php
            193
            194 $this->calculatePlusExpires("+1 year", $wireTimestamp, $previousTimestamp)
            195 ->shouldEqualApproximately(strtotime('+1 year', time()), 1.0e-9);
            196 }
            197
            198 function it_should_return_expiry_time_for_existing_1_year_plus_a_new_month()
            199 {
            200 $wireTimestamp = time();
            201 $previousTimestamp = strtotime('+11 months', time()); //already subbed for the next 11 momths
            202
            203 $this->calculatePlusExpires("+1 month", $wireTimestamp, $previousTimestamp)
            204 ->shouldEqualApproximately(strtotime('+1 year', time()), 1.0e-9);
            205 }
            206
            207 function it_should_return_expiry_time_for_existing_monthly_subscription_upgrade_to_year()
            208 {
            • Brian Hatchet
              Brian Hatchet :speech_balloon: @brianhatchet · 34 minutes ago
              Maintainer

              Yay, tests!

            • Please register or sign in to reply
          • Brian Hatchet
            Brian Hatchet :speech_balloon: @brianhatchet started a thread on the diff 34 minutes ago
            Controllers/api/v1/wire.php
            69 69 }
            70 70
            71 71 $manager = Core\Di\Di::_()->get('Wire\Manager');
            72
            73 $tier = $_POST['tier'] ?? '';
            • Brian Hatchet
              Brian Hatchet :speech_balloon: @brianhatchet · 34 minutes ago
              Maintainer

              Let's change this to a constant exposed in the Plus namesspace,

            • Please register or sign in to reply
          • Brian Hatchet
            Brian Hatchet :speech_balloon: @brianhatchet started a thread on the diff 34 minutes ago
            Core/Wire/Delegates/Plus.php
            60 60 return $wire;
            61 61 }
            62 62
            63 $user->setPlusExpires(strtotime('+30 days', $wire->getTimestamp()));
            63 // check the users tier if passed in. If not, it's a standard monthly subscription.
            64 switch ($tier) {
            65 case 'lifetime':
            66 $user->setPlusExpires(9999999999); //life
            67 break;
            • Brian Hatchet
              Brian Hatchet :speech_balloon: @brianhatchet · 34 minutes ago
              Maintainer

              Let's make these constants in the wire namespace

            • Please register or sign in to reply
          • Brian Hatchet
            Brian Hatchet :speech_balloon: @brianhatchet started a thread on the diff 34 minutes ago
            Core/Wire/Delegates/Plus.php
            65 79
            66 80 //$wire->setSender($user);
            67 81 return $wire;
            68 82 }
            69 83
            84 /**
            85 * Calculates a user's plus expirey date - factoring in upgrades to existing subscriptions.
            86 *
            87 * @param [String] $timespan - first param of strtotime().
            88 * @param [Integer] $wireTimestamp - the unix timestamp on the wire transaction.
            89 * @param [Integer] $previousTimestamp - the users previous subscription unix timestamp.
            90 * @return [Integer] the new unix expiry date.
            91 */
            92 public function calculatePlusExpires($timespan, $wireTimestamp, $previousTimestamp = null)
            93 {
            94 if ($previousTimestamp === 9999999999) {
            • Brian Hatchet
              Brian Hatchet :speech_balloon: @brianhatchet · 34 minutes ago
              Maintainer

              While this won't be a problem to 2286, let's make this a constant called LIFETIME

            • Please register or sign in to reply
          • Brian Hatchet
            Brian Hatchet :speech_balloon: @brianhatchet started a thread on the diff 34 minutes ago
            Core/Wire/Manager.php
            156 159
            157 160 return $this;
            158 161 }
            162
            163 public function setTier($tier = '')
            164 {
            • Brian Hatchet
              Brian Hatchet :speech_balloon: @brianhatchet · 34 minutes ago
              Maintainer

              Let's use some of the php doc decorators and set the default to one of the exposed constants

            • 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
          0 Assignees
          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
          7
          7 participants
          user avatar
          Brian Hatchet
          user avatar
          Emiliano Balbuena
          user avatar
          Rami Albatal
          user avatar
          Mark Harding
          user avatar
          Martin Santangelo
          user avatar
          Marcelo Rivera
          user avatar
          Ben Hayward
          Reference: minds/engine!279