Align /msearch output to legacy format

This commit is contained in:
Hypolite Petovan 2018-12-24 09:45:47 -05:00
parent 2fcd282e83
commit 4da3acb52a
2 changed files with 21 additions and 21 deletions

View file

@ -65,24 +65,14 @@ Example:
{ {
"query": "videogame gaming boardgame politics philosophy development programming php", "query": "videogame gaming boardgame politics philosophy development programming php",
"page": 1, "page": 1,
"itemsperpage": 80, "items_page": 100,
"count": 93, "total": 32,
"profiles": [ "results": [
{ {
"id": "2259",
"name": "Hyp🌧lite Pe☂ov🍃n (he/him)", "name": "Hyp🌧lite Pe☂ov🍃n (he/him)",
"username": "hypolite", "url": "https://friendica.mrpetovan.com/profile/hypolite",
"addr": "hypolite@friendica.mrpetovan.com", "photo": "https://friendica.mrpetovan.com/photo/27330388315ae4ed2b03e3c116980490-4.jpg?ts=1545521478",
"account_type": "People", "tags": "videogame gaming boardgame politics philosophy development programming php"
"pdesc": "Subpar geek, french/english, science, games, feminism, jokes and anything in between. Avatar by @DearMsDear@mastodon.art",
"locality": "Brooklyn",
"region": "New York",
"country": "USA",
"profile_url": "https://friendica.mrpetovan.com/profile/hypolite",
"dfrn_request": "https://friendica.mrpetovan.com/dfrn_request/hypolite",
"photo": "https://friendica.mrpetovan.com/photo/27330388315ae4ed2b03e3c116980490-4.jpg?ts=1541567135",
"tags": "videogame gaming boardgame politics philosophy development programming php",
"last_activity": "2018-45"
}, },
... ...
] ]

View file

@ -53,14 +53,24 @@ class MatchSearch
$profiles = $this->profileModel->getListForDisplay($pager->getItemsPerPage(), $pager->getStart(), $sql_where, $values); $profiles = $this->profileModel->getListForDisplay($pager->getItemsPerPage(), $pager->getStart(), $sql_where, $values);
$results = [];
foreach ($profiles as $profile) {
$results[] = [
'name' => $profile['name'],
'url' => $profile['profile_url'],
'photo' => $profile['photo'],
'tags' => $profile['tags'],
];
}
$count = $this->profileModel->getCountForDisplay($sql_where, $values); $count = $this->profileModel->getCountForDisplay($sql_where, $values);
$vars = [ $vars = [
'query' => $query, 'query' => $query,
'page' => $pager->getPage(), 'page' => $pager->getPage(),
'itemsperpage' => $pager->getItemsPerPage(), 'items_page' => $pager->getItemsPerPage(),
'count' => $count, 'total' => $count,
'profiles' => $profiles 'results' => $results
]; ];
return $response->withJson($vars); return $response->withJson($vars);