statistics.py
def analysis(keywords: str) -> str:
    """
    Returns statistics of usage according to the received keyword.

    :param keywords: keywords for statistics
    :return:
    """
    keywords = keywords.lower()
    no_stats_message = "Бот ранее не использовался, статистика не набрана"
    if "активность" in keywords and "фичи" in keywords:
        actions = collection.aggregate(
            [
                {"$group": {"_id": "$command", "count": {"$sum": 1}}},
                {"$sort": SON([("count", -1)])},
            ]
        )
        actions_stats = ""
        counter = 0
        for action in actions:
            counter += 1
            actions_stats += (
                u"\u2022 " + action["_id"] + " - " + str(action["count"]) + "\n"
            )
        activities = collection.aggregate(
            [
                {"$group": {"_id": "$user_id", "count": {"$sum": 1}}},
                {"$sort": SON([("count", -1)])},
            ]
        )
        activities_stats = ""
        for act in activities:
            counter += 1
            activities_stats += (
                u"\u2022 "
                + str(act["_id"])
                + " - "
                + "действий"
                + " - "
                + str(act["count"])
                + "\n"
            )
        if counter:
            general_stats = "Общая статистика: \n" + actions_stats + activities_stats
            return general_stats
        return no_stats_message
    elif "фичи" in keywords:
        actions = collection.aggregate(
            [
                {"$group": {"_id": "$command", "count": {"$sum": 1}}},
                {"$sort": SON([("count", -1)])},
            ]
        )
        actions_stats = "Статистика использования фичей: \n"
        counter = 0
        for action in actions:
            counter += 1
            actions_stats += (
                u"\u2022 " + action["_id"] + " - " + str(action["count"]) + "\n"
            )
        if counter:
            return actions_stats
        return no_stats_message
    elif "активность" in keywords:
        activities = collection.aggregate(
            [
                {"$group": {"_id": "$user_id", "count": {"$sum": 1}}},
                {"$sort": SON([("count", -1)])},
            ]
        )
        activities_stats = "Статистика активности пользователей: \n"
        counter = 0
        for act in activities:
            counter += 1
            activities_stats += (
                u"\u2022 "
                + str(act["_id"])
                + " - "
                + "действий"
                + " - "
                + str(act["count"])
                + "\n"
            )
        if counter:
            return activities_stats
        return no_stats_message
    return "Неверные ключи"

    Returns statistics of usage according to the received keyword.

    :param keywords: keywords for statistics
    :return:
    
Returns statistics of usage according to the received keyword.
Returns statistics of usage according to the received keyword .
def analysis(keywords: str) -> str:
    keywords = keywords.lower()
    no_stats_message = "Бот ранее не использовался, статистика не набрана"
    if "активность" in keywords and "фичи" in keywords:
        actions = collection.aggregate(
            [
                {"$group": {"_id": "$command", "count": {"$sum": 1}}},
                {"$sort": SON([("count", -1)])},
            ]
        )
        actions_stats = ""
        counter = 0
        for action in actions:
            counter += 1
            actions_stats += (
                u"\u2022 " + action["_id"] + " - " + str(action["count"]) + "\n"
            )
        activities = collection.aggregate(
            [
                {"$group": {"_id": "$user_id", "count": {"$sum": 1}}},
                {"$sort": SON([("count", -1)])},
            ]
        )
        activities_stats = ""
        for act in activities:
            counter += 1
            activities_stats += (
                u"\u2022 "
                + str(act["_id"])
                + " - "
                + "действий"
                + " - "
                + str(act["count"])
                + "\n"
            )
        if counter:
            general_stats = "Общая статистика: \n" + actions_stats + activities_stats
            return general_stats
        return no_stats_message
    elif "фичи" in keywords:
        actions = collection.aggregate(
            [
                {"$group": {"_id": "$command", "count": {"$sum": 1}}},
                {"$sort": SON([("count", -1)])},
            ]
        )
        actions_stats = "Статистика использования фичей: \n"
        counter = 0
        for action in actions:
            counter += 1
            actions_stats += (
                u"\u2022 " + action["_id"] + " - " + str(action["count"]) + "\n"
            )
        if counter:
            return actions_stats
        return no_stats_message
    elif "активность" in keywords:
        activities = collection.aggregate(
            [
                {"$group": {"_id": "$user_id", "count": {"$sum": 1}}},
                {"$sort": SON([("count", -1)])},
            ]
        )
        activities_stats = "Статистика активности пользователей: \n"
        counter = 0
        for act in activities:
            counter += 1
            activities_stats += (
                u"\u2022 "
                + str(act["_id"])
                + " - "
                + "действий"
                + " - "
                + str(act["count"])
                + "\n"
            )
        if counter:
            return activities_stats
        return no_stats_message
    return "Неверные ключи"
def analysis ( keywords : str ) -> str : keywords = keywords . lower ( ) no_stats_message = "Бот ранее не использовался, статистика не набрана" if "активность" in keywor s  nd "фичи  in keywords: actions = collection . aggregate ( [ { "$group" : { "_id" : "$command" , "count" : { "$sum" : 1 } } } , { "$sort" : SON ( [ ( "count" , - 1 ) ] ) } , ] ) actions_stats = "" counter = 0 for action in actions : counter += 1 actions_stats += ( u"\u2022 " + action [ "_id" ] + " - " + str ( action [ "count" ] ) + "\n" ) activities = collection . aggregate ( [ { "$group" : { "_id" : "$user_id" , "count" : { "$sum" : 1 } } } , { "$sort" : SON ( [ ( "count" , - 1 ) ] ) } , ] ) activities_stats = "" for act in activities : counter += 1 activities_stats += ( u"\u2022 " + str ( act [ "_id" ] ) + " - " + "действий" + " - " + str ( act [ "count" ] ) + "\n" ) if counter : general_stats = "Общая статистика: \n" + actions_stat  activities_s a s return general_stats return no_stats_message elif "фичи" in  ey ords: actions = collection . aggregate ( [ { "$group" : { "_id" : "$command" , "count" : { "$sum" : 1 } } } , { "$sort" : SON ( [ ( "count" , - 1 ) ] ) } , ] ) actions_stats = "Статистика использования фичей: \n" counter = 0 for action in actions : counter += 1 actions_stats += ( u"\u2022 " + action [ "_id" ] + " - " + str ( action [ "count" ] ) + "\n" ) if counter : return actions_stats return no_stats_message elif "активность" in keywor s: activities = collection . aggregate ( [ { "$group" : { "_id" : "$user_id" , "count" : { "$sum" : 1 } } } , { "$sort" : SON ( [ ( "count" , - 1 ) ] ) } , ] ) activities_stats = "Статистика активности пользователей: \n" counter = 0 for act in activities : counter += 1 activities_stats += ( u"\u2022 " + str ( act [ "_id" ] ) + " - " + "действий" + " - " + str ( act [ "count" ] ) + "\n" ) if counter : return activities_stats return no_stats_message return "Неверные ключи"
Returns statistics of usage according to the received keyword.
Returns statistics of usage according to the received keyword .
"""
    Returns statistics of usage according to the received keyword.

    :param keywords: keywords for statistics
    :return:
    """
None
keywords
str
keywords for statistics
keywords for statistics