Source code for luna_faces.app.handlers.faces_counter_handler

from sanic.response import HTTPResponse

from app.handlers.base_handler import BaseRequestHandler
from app.handlers.helpers import SearchFacesFilters
from crutches_on_wheels.web.query_getters import uuidGetter


[docs]class FacesCountHandler(BaseRequestHandler): """ Faces counter handler. """
[docs] async def get(self) -> HTTPResponse: """ Get face count by filters. See `spec_get_face_count`_. .. _spec_get_face_count: _static/api.html#operation/getFaceCount Returns: response json with face count and status code 200 """ filters = SearchFacesFilters().loadFromQuery(self.getQueryParam) faceCount = await self.facesContext.getFacesCount(filters=filters) return self.success(200, outputJson={"faces_count": faceCount})
[docs]class FacesAttributesCountHandler(BaseRequestHandler): """ Face counter handler: count faces with attributes """
[docs] async def get(self) -> HTTPResponse: """ Count faces with attributes. See `spec_get_face_attribute_count`_. .. _spec_get_face_attribute_count: _static/api.html#operation/getFaceAttributeCount Returns: response json with face count and status code 200 """ accountId = self.getQueryParam("account_id", uuidGetter) faceCount = await self.facesContext.getFacesAttributesCount(accountId=accountId) return self.success(200, outputJson={"faces_count": faceCount})