Get a user update statistics

@param Activity $activity
@param NewsItem $newsItem
@return array
483687
public function getUserUpdate(Activity $activity, NewsItem $newsItem)
    {
        //LinkedIn API seems broken, re-enable when it works again.
        //return [];

        return $this->connect->request(
            'GET',
            'people/~/network/updates/key='.$newsItem->getUpdateKey(),
            [
                'query' => [
                    'format' => 'json',
                ]
            ]
        );
    }
563583
public function getUserExecutions(core_kernel_classes_Resource $assembly, $userUri)
    {
        $query = $this->getQueryBuilder()
            ->select("*")
            ->from(self::TABLE_NAME)
            ->where(self::COLUMN_DELIVERY_ID . " = :deliveryId")
            ->andWhere(self::COLUMN_USER_ID . " = :userId")
            ->setParameter("deliveryId", $assembly->getUri())
            ->setParameter("userId", $userUri)
        ;

        return array_map(function($row) {
            return $this->parseQueryResult($row);
        }, $query->execute()->fetchAll());
    }
1206688
public function pagesAffectedByChanges() {
    	$parent = $this->Parent();
    	$urls 	= array($this->Link());
		
		// add all parent (holders)
		while($parent && $parent->ParentID > -1 && $parent instanceof NewsHolder) {
    		$urls[] = $parent->Link();
    		$parent = $parent->Parent();
   		}
   		
   		$this->extend('updatePagesAffectedByChanges', $urls);
    	
    	return $urls;
  	}
739367
public function updateNewsletter(array $data, $user, $partner)
    {
        $subscription = new \PlaygroundPartnership\Entity\Subscriber();
        $subscription->setPartner($partner)
            ->setUser($user)
            ->setActive($data['optin']);
        $subscription = $this->getSubscriberMapper()->update($subscription);

        return $subscription;
    }
343507
private function searchUrl(NewsItemEntity $newsItem)
    {
        $pattern = '/[-a-zA-Z0-9:%_\+.~#?&\/\/=]{2,256}\.[a-z]{2,10}\b(\/[-a-zA-Z0-9:%_\+.~#?&\/\/=]*)?/i';

        if (!preg_match($pattern, $newsItem->getMessage(), $matches)) {
            // No link found, so set link data to null.
            return $this->unsetUrl($newsItem);
        }

        $url = $matches[0];

        $result = $this->scrapeUrl($url);

        if (empty($result)) {
            return $this->unsetUrl($newsItem);
        }

        $newsItem->setLinkUrl(ParserUtil::sanitizeUrl($url));
        $newsItem->setLinkTitle($result['title']);
        $newsItem->setLinkDescription($result['description']);

        return $newsItem;
    }
106287
def __get_activity_by_name(self, name, category_id = None, resurrect = True):
        """"""

        if category_id:
            query = """
                       SELECT a.id, a.name, a.deleted, coalesce(b.name, ?) as category
                         FROM activities a
                    LEFT JOIN categories b ON category_id = b.id
                        WHERE lower(a.name) = lower(?)
                          AND category_id = ?
                     ORDER BY a.deleted, a.id desc
                        LIMIT 1
            """

            res = self.fetchone(query, (self._unsorted_localized, name, category_id))
        else:
            query = """
                       SELECT a.id, a.name, a.deleted, coalesce(b.name, ?) as category
                         FROM activities a
                    LEFT JOIN categories b ON category_id = b.id
                        WHERE lower(a.name) = lower(?)
                     ORDER BY a.deleted, a.id desc
                        LIMIT 1
            """
            res = self.fetchone(query, (self._unsorted_localized, name, ))

        if res:
            keys = ('id', 'name', 'deleted', 'category')
            res = dict([(key, res[key]) for key in keys])
            res['deleted'] = res['deleted'] or False

            # if the activity was marked as deleted, resurrect on first call
            # and put in the unsorted category
            if res['deleted'] and resurrect:
                update = """
                            UPDATE activities
                               SET deleted = null, category_id = -1
                             WHERE id = ?
                        """
                self.execute(update, (res['id'], ))

            return res

        return None
983140
protected function cartUpdates($isNewItem = false, $keepDiscount = false)
    {
        $this->updateTotals($keepDiscount);

        $this->storeCartData($isNewItem);

        return $this->toArray();
    }
591717
public static function getSendTargetUser($activity) {
    // Get target account.
    if (isset($activity->field_activity_recipient_user) && !empty($activity->field_activity_recipient_user->target_id)) {
      $target_id = $activity->field_activity_recipient_user->target_id;
      $target_account = \Drupal::entityTypeManager()
        ->getStorage('user')
        ->load($target_id);
      return $target_account;
    }
  }
630011
public function getDeliveryExecutionsByStatus($userUri, $status)
    {
        $query = $this->getQueryBuilder()
            ->select("*")
            ->from(self::TABLE_NAME)
            ->where(self::COLUMN_USER_ID . " = :userId")
            ->andWhere(self::COLUMN_STATUS . " = :status")
            ->setParameter("userId", $userUri)
            ->setParameter("status", $status)
        ;

        return array_map(function($row) {
            return $this->parseQueryResult($row);
        }, $query->execute()->fetchAll());
    }
319491
public function getTemplateData($context, $user = null, $extraData = [])
    {
        // useful global data
        $data = [
            'ThemeDirs' => new ArrayList(SSViewer::get_themes()),
            'SiteConfig' => SiteConfig::current_site_config(),
        ];

        // the context object, keyed by it's class name
        $clsPath = explode('\\', get_class($context));
        $data[end($clsPath)] = $context;
        $data['Context'] = $context;

        // data as defined by the context object
        $contextData = method_exists($context, 'getNotificationTemplateData') ? $context->getNotificationTemplateData() : null;
        if (is_array($contextData)) {
            $data = array_merge($data, $contextData);
        }

        // the member the notification is being sent to
        $data['Member'] = $user;

        // extra data
        $data = array_merge($data, $extraData);

        return ArrayData::create($data);
    }
277534
public function getChanged(UserUpdater $update)
    {
        $changed = [];
        $ref = new \ReflectionClass($this);
        foreach ($ref->getProperties() as $prop) {
            $method = 'get' . ucfirst($prop->getName());
            $newVal = $update->$method();
            if ($this->$method() != $newVal) {
                $changed[$prop->getName()] = $newVal;
            }
        }

        return $changed;
    }
762717
public function items($params = [], \DateTime $updatedAfter = null)
    {
        $params = array_merge($this->auth->getCredentials(), $params);

        if ($updatedAfter !== null) {
            $this->client->addRequestHeaders([
                'If-Modified-Since' => $updatedAfter->format('D, d M Y H:i:s')
            ]);
        }

        return $this->client->get(self::ACTION_NAME, $params);
    }
13678
public function updateActivityToTargets($foreign_id, $time, $new_targets = [], $added_targets = [], $removed_targets = [])
    {
        $data = [
            'foreign_id' => $foreign_id,
            'time'       => $time,
        ];

        if ($new_targets) {
            $data['new_targets'] = $new_targets;
        }

        if ($added_targets) {
            $data['added_targets'] = $added_targets;
        }

        if ($removed_targets) {
            $data['removed_targets'] = $removed_targets;
        }
        return $this->makeHttpRequest("feed_targets/{$this->slug}/{$this->user_id}/activity_to_targets/", 'POST', $data, null, 'feed_targets', 'write');
    }
1186579
public void updateStatus() {
        Optional<Activity> activity = api.getActivity();
        ObjectNode updateStatus = JsonNodeFactory.instance.objectNode()
                .put("op", GatewayOpcode.STATUS_UPDATE.getCode());
        ObjectNode data = updateStatus.putObject("d")
                .put("status", api.getStatus().getStatusString())
                .put("afk", false)
                .putNull("since");
        ObjectNode activityJson = data.putObject("game");
        activityJson.put("name", activity.isPresent() ? activity.get().getName() : null);
        activityJson.put("type", activity.map(g -> g.getType().getId()).orElse(0));
        activity.ifPresent(g -> g.getStreamingUrl().ifPresent(url -> activityJson.put("url", url)));
        logger.debug("Updating status (content: {})", updateStatus);
        websocket.get().sendText(updateStatus.toString());
    }
82693
public function update(SmsActivity $activity): SmsActivity
    {
        $id = $activity->getId();

        $activity->setId(null);

        $response = $this->client->put($this->prepareUrlForKey('update-sms', ['id' => $id]), [], $activity->jsonSerialize());
        $responseData = $response->getDecodedBody();

        return new SmsActivity($responseData);
    }
949919
public function getTweetsFromUser($username, $count = 10, $cacheMinutes = 30, $returnEntities = true)
    {
        $count = $this->getVerifiedCount($count, 1, 200);

        $endpoint = '/statuses/user_timeline.json';

        $url = $this->urlHelper->joinSlugs([$this->baseUrl, $this->apiVersion, $endpoint]);

        $data = [
            'screen_name' => $username,
            'count' => $count
        ];

        $headers = [
            'Authorization' => 'Bearer ' . $this->requestAppAccessToken()
        ];

        $response = $this->courier->get($url, $data, $headers, $cacheMinutes);

        if ($returnEntities)
        {
            $tweets = $response->toArray();
            $response = $this->createTweetEntities($tweets);
        }

        return $response;
    }
417796
public function editActivity(Activity $activity)
    {
        $this->om->persist($activity);
        $this->om->flush();
        $this->initializePermissions($activity);

        return $activity;
    }