mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-22 00:51:01 +00:00
feat: Implement http status filtering in entries API
This commit is contained in:
parent
7a635c3b5a
commit
c42a4a308f
2 changed files with 21 additions and 2 deletions
|
@ -280,6 +280,18 @@ class EntryRestController extends WallabagRestController
|
|||
* example="example.com",
|
||||
* )
|
||||
* ),
|
||||
* @OA\Parameter(
|
||||
* name="http_status",
|
||||
* in="query",
|
||||
* description="filter entries with matching http status code",
|
||||
* required=false,
|
||||
* @OA\Schema(
|
||||
* type="integer",
|
||||
* minimum=100,
|
||||
* maximum=527,
|
||||
* example="200",
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="Returned when successful"
|
||||
|
@ -306,6 +318,7 @@ class EntryRestController extends WallabagRestController
|
|||
$since = $request->query->get('since', 0);
|
||||
$detail = strtolower($request->query->get('detail', 'full'));
|
||||
$domainName = (null === $request->query->get('domain_name')) ? '' : (string) $request->query->get('domain_name');
|
||||
$httpStatus = (!\array_key_exists((int) $request->query->get('http_status'), Response::$statusTexts)) ? null : (int) $request->query->get('http_status');
|
||||
|
||||
try {
|
||||
/** @var Pagerfanta $pager */
|
||||
|
@ -320,7 +333,8 @@ class EntryRestController extends WallabagRestController
|
|||
$tags,
|
||||
$detail,
|
||||
$domainName,
|
||||
$isNotParsed
|
||||
$isNotParsed,
|
||||
$httpStatus
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
throw new BadRequestHttpException($e->getMessage());
|
||||
|
|
|
@ -285,13 +285,14 @@ class EntryRepository extends ServiceEntityRepository
|
|||
* @param string $tags
|
||||
* @param string $detail 'metadata' or 'full'. Include content field if 'full'
|
||||
* @param string $domainName
|
||||
* @param int $httpStatus
|
||||
* @param bool $isNotParsed
|
||||
*
|
||||
* @todo Breaking change: replace default detail=full by detail=metadata in a future version
|
||||
*
|
||||
* @return Pagerfanta
|
||||
*/
|
||||
public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'asc', $since = 0, $tags = '', $detail = 'full', $domainName = '', $isNotParsed = null)
|
||||
public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = 'created', $order = 'asc', $since = 0, $tags = '', $detail = 'full', $domainName = '', $isNotParsed = null, $httpStatus = null)
|
||||
{
|
||||
if (!\in_array(strtolower($detail), ['full', 'metadata'], true)) {
|
||||
throw new \Exception('Detail "' . $detail . '" parameter is wrong, allowed: full or metadata');
|
||||
|
@ -350,6 +351,10 @@ class EntryRepository extends ServiceEntityRepository
|
|||
}
|
||||
}
|
||||
|
||||
if (\is_int($httpStatus)) {
|
||||
$qb->andWhere('e.httpStatus = :httpStatus')->setParameter('httpStatus', $httpStatus);
|
||||
}
|
||||
|
||||
if (\is_string($domainName) && '' !== $domainName) {
|
||||
$qb->andWhere('e.domainName = :domainName')->setParameter('domainName', $domainName);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue