Add nbEntries to the API tags list response

So client will be able to do the same as in the web UI.

Also remove empty `div` from the tags template.
This commit is contained in:
Jeremy Benoist 2022-09-23 15:16:38 +02:00
parent a452bb6204
commit 812b4a906f
No known key found for this signature in database
GPG key ID: 7168D5DD29F38552
3 changed files with 2 additions and 7 deletions

View file

@ -23,7 +23,7 @@ class TagRestController extends WallabagRestController
$tags = $this->getDoctrine() $tags = $this->getDoctrine()
->getRepository('WallabagCoreBundle:Tag') ->getRepository('WallabagCoreBundle:Tag')
->findAllTags($this->getUser()->getId()); ->findAllFlatTagsWithNbEntries($this->getUser()->getId());
$json = $this->get('jms_serializer')->serialize($tags, 'json'); $json = $this->get('jms_serializer')->serialize($tags, 'json');

View file

@ -33,8 +33,4 @@
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
<div>
</div>
{% endblock %} {% endblock %}

View file

@ -20,14 +20,13 @@ class TagRestControllerTest extends WallabagApiTestCase
$this->assertGreaterThan(0, $content); $this->assertGreaterThan(0, $content);
$this->assertArrayHasKey('id', $content[0]); $this->assertArrayHasKey('id', $content[0]);
$this->assertArrayHasKey('label', $content[0]); $this->assertArrayHasKey('label', $content[0]);
$this->assertArrayHasKey('nbEntries', $content[0]);
$tagLabels = array_map(function ($i) { $tagLabels = array_map(function ($i) {
return $i['label']; return $i['label'];
}, $content); }, $content);
$this->assertNotContains($this->otherUserTagLabel, $tagLabels, 'There is a possible tag leak'); $this->assertNotContains($this->otherUserTagLabel, $tagLabels, 'There is a possible tag leak');
return end($content);
} }
public function testDeleteUserTag() public function testDeleteUserTag()