From 4da3acb52ae282405acae179ae24b9819215510f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 24 Dec 2018 09:45:47 -0500 Subject: [PATCH] Align `/msearch` output to legacy format --- docs/Protocol.md | 22 ++++++--------------- src/classes/Controllers/Api/MatchSearch.php | 20 ++++++++++++++----- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/Protocol.md b/docs/Protocol.md index a1e8cd5..3dafd02 100644 --- a/docs/Protocol.md +++ b/docs/Protocol.md @@ -65,24 +65,14 @@ Example: { "query": "videogame gaming boardgame politics philosophy development programming php", "page": 1, - "itemsperpage": 80, - "count": 93, - "profiles": [ + "items_page": 100, + "total": 32, + "results": [ { - "id": "2259", "name": "Hyp🌧lite Pe☂ov🍃n (he/him)", - "username": "hypolite", - "addr": "hypolite@friendica.mrpetovan.com", - "account_type": "People", - "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" + "url": "https://friendica.mrpetovan.com/profile/hypolite", + "photo": "https://friendica.mrpetovan.com/photo/27330388315ae4ed2b03e3c116980490-4.jpg?ts=1545521478", + "tags": "videogame gaming boardgame politics philosophy development programming php" }, ... ] diff --git a/src/classes/Controllers/Api/MatchSearch.php b/src/classes/Controllers/Api/MatchSearch.php index a45aff3..17e9969 100644 --- a/src/classes/Controllers/Api/MatchSearch.php +++ b/src/classes/Controllers/Api/MatchSearch.php @@ -53,14 +53,24 @@ class MatchSearch $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); $vars = [ - 'query' => $query, - 'page' => $pager->getPage(), - 'itemsperpage' => $pager->getItemsPerPage(), - 'count' => $count, - 'profiles' => $profiles + 'query' => $query, + 'page' => $pager->getPage(), + 'items_page' => $pager->getItemsPerPage(), + 'total' => $count, + 'results' => $results ]; return $response->withJson($vars);