Merge pull request #10430 from annando/api-trends
API: Send "history" section for trends
This commit is contained in:
		
				commit
				
					
						3ece803816
					
				
			
		
					 2 changed files with 8 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -45,7 +45,8 @@ class Trends extends BaseApi
 | 
			
		|||
		$tags = Tag::getGlobalTrendingHashtags(24, 20);
 | 
			
		||||
		foreach ($tags as $tag) {
 | 
			
		||||
			$tag['name'] = $tag['term'];
 | 
			
		||||
			$hashtag = new \Friendica\Object\Api\Mastodon\Tag(DI::baseUrl(), $tag);
 | 
			
		||||
			$history = [['day' => (string)time(), 'uses' => (string)$tag['score'], 'accounts' => (string)$tag['authors']]];
 | 
			
		||||
			$hashtag = new \Friendica\Object\Api\Mastodon\Tag(DI::baseUrl(), $tag, $history);
 | 
			
		||||
			$trending[] = $hashtag->toArray();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,6 +35,8 @@ class Tag extends BaseDataTransferObject
 | 
			
		|||
	protected $name;
 | 
			
		||||
	/** @var string */
 | 
			
		||||
	protected $url = null;
 | 
			
		||||
	/** @var array */
 | 
			
		||||
	protected $history = [];
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Creates a hashtag record from an tag-view record.
 | 
			
		||||
| 
						 | 
				
			
			@ -43,9 +45,10 @@ class Tag extends BaseDataTransferObject
 | 
			
		|||
	 * @param array   $tag     tag-view record
 | 
			
		||||
	 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct(BaseURL $baseUrl, array $tag)
 | 
			
		||||
	public function __construct(BaseURL $baseUrl, array $tag, array $history = [])
 | 
			
		||||
	{
 | 
			
		||||
		$this->name = strtolower($tag['name']);
 | 
			
		||||
		$this->url  = $baseUrl . '/search?tag=' . urlencode($this->name);
 | 
			
		||||
		$this->name    = strtolower($tag['name']);
 | 
			
		||||
		$this->url     = $baseUrl . '/search?tag=' . urlencode($this->name);
 | 
			
		||||
		$this->history = $history;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue