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 152
    • Issues 152
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 39
    • Merge Requests 39
  • 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
  • !214

Open
Opened 6 hours ago by Brian Hatchet@brianhatchet:speech_balloon:
  • Report abuse
Report abuse

(fix) Firehose all entities saving properly

This iteration of the firehose does a bunch of things.

It properly saves videos, images and blogs to both elasticsearch and cassandra.

Finally got the mappings working properly. moderated entities will update elasticsearch with moderator_guid and @moderated

We need to insert the object:blog, object:video and object:image fields in their respective types in elasticsearch (calls are in postman)

I have also updated the elasticsearch_provisioner to add those fields for development

Edited 1 hour ago by Brian Hatchet

Check out, review, and merge locally

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

git fetch https://gitlab.com/brianhatchet/engine.git firehose-images-video-saving-properly
git checkout -b brianhatchet/engine-firehose-images-video-saving-properly 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 brianhatchet/engine-firehose-images-video-saving-properly

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 brianhatchet:firehose-images-video-saving-properly into master
The source branch is 4 commits behind the target branch
Open in Web IDE
  • Email patches
  • Plain diff
Pipeline #67074063 passed for 240e5431 on brianhatchet:firehose-images-video-saving-properly
      Requires 2 more approvals from Devs.
      Emiliano Balbuena
      Emiliano Balbuena
      Martin Santangelo
      Martin Santangelo
      Marcelo Rivera
      Marcelo Rivera
      Rami Albatal
      Rami Albatal
      Mark Harding
      Mark Harding
      Ready to be merged automatically. Ask someone with write access to this repository to merge this request

      Allows commits from members who can merge to the target branch

      Deletes source branch

      • Discussion 5
      • Commits 5
      • Pipelines 4
      • Changes 12
      0/5 discussions resolved
      • Loading...
      • Brian Hatchet :speech_balloon: @brianhatchet changed milestone to %sprint: Hipster Hedgehog 6 hours ago

        changed milestone to %sprint: Hipster Hedgehog

      • Brian Hatchet :speech_balloon: @brianhatchet added 1 commit 1 hour ago

        added 1 commit

        • 240e5431 - Everything working and saving edition

        Compare with previous version

      • Brian Hatchet :speech_balloon: @brianhatchet unmarked as a Work In Progress 1 hour ago

        unmarked as a Work In Progress

      • Brian Hatchet :speech_balloon: @brianhatchet changed title from WIP: Firehose images video saving properly to Firehose all entities saving properly 1 hour ago

        changed title from WIP: Firehose images video saving properly to Firehose all entities saving properly

      • Brian Hatchet :speech_balloon: @brianhatchet changed the description 1 hour ago

        changed the description

      • Brian Hatchet :speech_balloon: @brianhatchet assigned to @brianhatchet 1 hour ago

        assigned to @brianhatchet

      • Brian Hatchet :speech_balloon: @brianhatchet changed title from Firehose all entities saving properly to (fix) Firehose all entities saving properly 1 hour ago

        changed title from Firehose all entities saving properly to (fix) Firehose all entities saving properly

      • Emiliano Balbuena
        Emiliano Balbuena @edgebal started a discussion on the diff 8 minutes ago
        Core/Blogs/Manager.php
        145 145 */
        146 146 public function update(Blog $blog)
        147 147 {
        148 $shouldReindex = $blog->isDirty('deleted');
        148 $shouldReindex = $blog->isDirty('deleted') || $blog->isDirty('moderatorGuid');
        • Emiliano Balbuena
          Emiliano Balbuena @edgebal · 8 minutes ago
          Developer

          This is safe to be rollbacked as it was. shouldReindex refers to indexing onto the old entities_by_time Cassandra table.

        Please register or sign in to reply
      • Emiliano Balbuena
        Emiliano Balbuena @edgebal started a discussion on the diff 8 minutes ago
        Entities/File.php
        160 * @return int moderator guid
        161 */
        162 public function getModeratorGuid() {
        163 return $this->moderator_guid;
        164 }
        165
        166 public function setModeratorGuid(int $moderatorGuid) {
        167 $this->moderator_guid = $moderatorGuid;
        168 return $this;
        169 }
        170
        171 public function getTimeModerated() {
        172 return $this->time_moderated;
        173 }
        174 public function setTimeModerated(int $time) {
        175 $this->time_moderated = $time;
        • Emiliano Balbuena
          Emiliano Balbuena @edgebal · 8 minutes ago
          Developer

          Don't forget returning $this.

        Please register or sign in to reply
      • Emiliano Balbuena
        Emiliano Balbuena @edgebal started a discussion on the diff 8 minutes ago
        Core/Feeds/Firehose/Manager.php
        53 67 }
        54 68
        55 69 return $response->filter(function ($entity) {
        56 return $entity->get('moderator_guid') === null;
        70 return empty($entity->getModeratorGuid());
        • Emiliano Balbuena
          Emiliano Balbuena @edgebal · 8 minutes ago
          Developer

          Not sure about using empty() here. PHP interprets '' and '0' as falsy values.

        Please register or sign in to reply
      • Emiliano Balbuena
        Emiliano Balbuena @edgebal started a discussion on the diff 8 minutes ago
        Core/Feeds/Firehose/Manager.php
        68 80 */
        69 81 public function save(
        70 82 $entity,
        71 83 User $moderator,
        72 int $reasonCode = null,
        73 int $subreasonCode = null,
        74 84 int $time = null)
        75 85 {
        76 86 if (!$time) {
        77 87 $time = time();
        78 88 }
        79 89
        90 //Save the entity
        91 $this->saveEntity($entity, $moderator, $time);
        92
        93 if ($entity->getType() == 'activity' && $entity->get('entity_guid')) {
        • Emiliano Balbuena
          Emiliano Balbuena @edgebal · 8 minutes ago
          Developer

          Let's use strict comparison (===). Also, we need to be 100% sure that $entity has a getType() method. Maybe comparing with instanceof Activity?

        Please register or sign in to reply
      • Emiliano Balbuena
        Emiliano Balbuena @edgebal started a discussion on the diff 8 minutes ago
        Core/Search/Mappings/ObjectBlogMapping.php
        33 33 'license' => [ 'type' => 'text', '$exportGetter' => 'getLicense' ],
        34 34 'rating' => [ 'type' => 'integer', '$exportField' => 'rating' ],
        35 35 'nsfw' => [ 'type' => 'array', '$exportGetter' => 'getNsfw' ],
        36 'moderator_guid' => [ 'type' => 'text'],
        • Emiliano Balbuena
          Emiliano Balbuena @edgebal · 8 minutes ago
          Developer

          Spacing before the ].

        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
      Brian Hatchet's avatar Brian Hatchet @brianhatchet
      Assign to
      sprint: Hipster Hedgehog
      Milestone
      sprint: Hipster Hedgehog
      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
      Emiliano Balbuena
      user avatar
      Martin Santangelo
      user avatar
      Marcelo Rivera
      user avatar
      Rami Albatal
      user avatar
      Mark Harding
      user avatar
      Ben Hayward
      user avatar
      Brian Hatchet
      Reference: minds/engine!214