async def top(search_id: int = Path(..., gt=0)) -> List[StatsModel]:
    """This function provides the get method to route /stats/top/{search_id}

    :param search_id: primary key for finding necessary record
    :return: list of all Stats records for specified Searches record
    :rtype: List[StatsModel]
    """

    stats_all = Stats.filter(
        search_id=search_id).order_by('-ads_amount').limit(5)
    return await StatsModel.from_queryset(stats_all)
async def stats(search_id: int = Query(..., gt=0),
                from_datetime: datetime = Query(datetime.fromtimestamp(0)),
                to_datetime: datetime = Query(
                    None, description='Format: YYYY-mm-DDTHH:MM:SS')):
    """This method provides the get method to route /stats/

    :param search_id: primary key for finding necessary Searches record
    :param from_datetime: first field of datetime interval
    :param to_datetime: second filed of datetime interval
    :return: list of all Stats records for specified Searches record
    """
    filters = {
        'search_id': search_id,
        'created_at__gte': from_datetime,
    }

    if to_datetime:
        filters['created_at__lte'] = to_datetime

    stats_queryset = Stats.filter(**filters)
    return await StatsModel.from_queryset(stats_queryset)