Refreshes stale twitter profiles. One call currently only refreshes
180 profiles to minimize bumping into twitter's rate limiting.

@return bool
430315
public static function refreshProfiles()
    {
        $profile = new static();

        $staleDate = time() - ($profile->daysUntilStale() * 86400);

        $profiles = static::findAll([
            'where' => [
                'access_token <> ""',
                'last_refreshed < '.$staleDate, ],
            'limit' => $profile->numProfilesToRefresh(),
            'sortBy' => 'last_refreshed DESC', ]);

        foreach ($profiles as $profile) {
            $profile->refreshProfile();
        }

        return true;
    }
25462
public function refresh()
    {
        if ($this->ID && $this->HailID) {
            try {
                $api_client = new Client();
                $data = $api_client->getOne($this);
            } catch (\Exception $ex) {
                return $this;
            }
            if (count($data) > 0) {
                $this->importHailData($data);
            }
        }

        return $this;
    }
705639
public function actionRefresh()
    {
        $model = new Route();
        $model->invalidate();
        Yii::$app->getResponse()->format = 'json';
        return $model->getRoutes();
    }
270365
protected function refresh_info()
    {

        $this->pid   = (int)getmypid();
        $this->gid   = (int)getmygid();
        $this->inode = (int)getmyinode();
        $this->uid   = (int)getmyuid();
        $this->user  = (string)get_current_user();
        $this->uname = posix_uname();

        return true;
    }
342919
private function update_metrics() {
    $now = time();
    if (($this->metrics['interval_start'] + $this->config['streaming_metrics_interval']) > $now)
      return false;

    $this->metrics['tps'] = round( ($this->metrics['tweets'] - $this->metrics['last_tweets']) / $this->config['streaming_metrics_interval'], 2);
    $this->metrics['bps'] = round( ($this->metrics['bytes'] - $this->metrics['last_bytes']) / $this->config['streaming_metrics_interval'], 2);

    $this->metrics['last_bytes'] = $this->metrics['bytes'];
    $this->metrics['last_tweets'] = $this->metrics['tweets'];
    $this->metrics['interval_start'] = $now;
    return $this->metrics;
  }
958444
public static function getUser()
    {
        $tweetStore = Store::get('Tweet');

        $consumerKey = Setting::getSetting('twitter', 'consumer_key');
        $consumerSecret = Setting::getSetting('twitter', 'consumer_secret');
        $accessToken = Setting::getSetting('twitter', 'access_token');
        $accessTokenSecret = Setting::getSetting('twitter', 'access_token_secret');

        $twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);

        if (self::canCallAPI()) {
            self::updateLastAPICall();

            $statuses = $twitter->load(Twitter::ME);
            foreach ($statuses as $s) {
                if (!$tweetStore->getByTwitterIdForScope($s->id, 'user')) {
                    $t = new Tweet;
                    $t->setTwitterId($s->id);
                    $t->setText($s->text);
                    $t->setHtmlText(Twitter::clickable($s));
                    $t->setScreenname($s->user->screen_name);
                    $t->setPosted($s->created_at);
                    $t->setCreatedDate(new \DateTime());
                    $t->setScope('user');
                    $tweetStore->saveByInsert($t);
                }
            }
        }
    }
1276944
public function getRefreshToken()
    {
        if (is_string($this->refresh_token) && $this->isValidToken() ){

            $this->refreshToken = $this->token_type . ' ' . $this->refresh_token;

            return $this->refreshToken;
        }

        return false;
    }
1197515
public function reload(): bool
	{
		if($this->isPersisted)
		{
			$model = static::get($this->getPrimaryKeyValue());

			if($model !== false)
			{
				$this->original = $this->columns = $model->getRawColumnValues();

				$this->related = $model->getRelated();

				return true;
			}
		}

		return false;
	}
780940
public function refreshExpiredCache($environment = null, $forceRefresh = false)
    {
        $hasBeenRefreshed = false;
        foreach ($this->cacheManagers as $cacheManager) {
            $hasBeenRefreshed =  $cacheManager->refreshExpiredCache($environment, $forceRefresh) || $hasBeenRefreshed;
        }
        return $hasBeenRefreshed;
    }
794815
public static function syncAllUsers()
	{
		// @TODO: chunk this to 1000 users at a time

		$db = \App::get('db');

		$query = "SELECT id FROM `#__users`;";

		$db->setQuery($query);

		$result = $db->loadColumn();

		if ($result === false)
		{
			return false;
		}

		foreach ($result as $row)
		{
			self::syncUser($row);

			if (is_array(self::$errors['fatal']) && !empty(self::$errors['fatal'][0]))
			{
				// If there's a fatal error, go ahead and stop
				return self::$errors;
			}
		}

		if (!empty(self::$errors['fatal'][0]) || !empty(self::$errors['warning'][0]))
		{
			return self::$errors;
		}
		else
		{
			return self::$success;
		}
	}
1243116
public function reloadErrorJobs()
    {
        $redis = $this->getRedisChildClient();
        $count = 0;
        while ($data = $redis->rpoplpush($this->errorKey, $this->queueKey)) {
            $count++;
        }

        return $count;
    }
610008
public function refresh()
    {
        $token = Auth::guard()->refresh();

        return response()->json([
            'status' => 'ok',
            'token' => $token,
            'expires_in' => Auth::guard()->factory()->getTTL() * 60
        ]);
    }
342859
public function refresh($forceForever = false, $resetClaims = false)
    {
        if ($cache = $this->getCachedToken()) {
            return $cache;
        }

        // refresh token
        $token = $this->jwt->parser()->parseToken();
        $key = md5($token);
        $refreshToken = JWTAuth::refresh($token, $forceForever, $resetClaims);

        // cache newly refreshed token
        $this->setCachedToken($key, $refreshToken);

        return $this->cachedToken;
    }
915392
public function mustRefresh()
    {
        if ($this->fileExists()) {
            $this->_cleanFilesStack();
            $_dest = new \SplFileInfo($this->getDestinationRealPath());
            if (!empty($this->files_stack)) {
                foreach ($this->files_stack as $_file) {
                    if ($_file->getMTime() > $_dest->getMTime()) {
                        return true;
                    }
                }
                return false;
            }
        }
        return true;
    }
1018037
def refresh(self):
        
        endpoint = '/refresh'

        payload = {
            'accessToken': self.access_token,
            'clientToken': self.client_token,
        }
        rep = self._ygg_req(endpoint, payload)
        if not rep or 'error' in rep:
            return False

        self.access_token = rep['accessToken']
        self.client_token = rep['clientToken']
        self.selected_profile = rep['selectedProfile']
        return True
278653
public function getRefreshToken($refresh_token)
    {
        $result = $this->client->getItem(array(
            "TableName"=> $this->config['refresh_token_table'],
            "Key" => array('refresh_token'   => array('S' => $refresh_token))
        ));
        if ($result->count()==0) {
            return false ;
        }
        $token = $this->dynamo2array($result);
        $token['expires'] = strtotime($token['expires']);

        return $token;
    }
1363933
public static function canCallAPI()
    {
        $lastCall = Setting::getSetting('twitter', 'last_api_call');

        if ($lastCall == null) {
            return true;
        } else {
            $lastCall = new \DateTime($lastCall);
        }

        $now = new \DateTime();
        $interval = $lastCall->diff($now);

        // Are we at least one minute ago?
        if ($interval->i >= 1) {
            return true;
        } else {
            return false;
        }
    }