コード例 #1
0
def broadcast_history_list_helper(broadcast) -> dict:
    results = {
        "created_by":
        user_basic_information_helper(broadcast["created_by"]),
        "status":
        'Completed' if broadcast["total"] == broadcast["processed"] > 0 else
        ('Sending' if broadcast["total"] > broadcast["processed"] >=
         broadcast["sent"] > 0 else 'Scheduled'),
        "tags":
        broadcast["tags"],
        "exclude":
        broadcast["exclude"],
        "send_to_all":
        broadcast["send_to_all"],
        "send_at":
        broadcast["send_at"],
        "sent":
        broadcast["sent"],
        "processed":
        broadcast["processed"],
        "total":
        broadcast["total"],
        "id":
        str(broadcast["_id"]),
    }
    return clean_dict_helper(results)
コード例 #2
0
ファイル: flows.py プロジェクト: yuekaidi/adminhub_backend
def flow_helper(flow) -> dict:
    for f in flow.get('flow', []):
        f['type'] = str(FlowTypeEnumOut(f['type']))
    results = {
        **flow,
        "id": str(flow["_id"]),
    }
    return clean_dict_helper(results)
コード例 #3
0
ファイル: helper.py プロジェクト: yuekaidi/adminhub_backend
def bot_user_helper(bot_user) -> dict:
    return clean_dict_helper({
        **bot_user, "id":
        str(bot_user["_id"]),
        "last_message":
        message_helper(bot_user['last_message'])
        if bot_user.get('last_message') else None
    })
コード例 #4
0
def convo_message_search_helper(message) -> dict:
    return {
        **message,
        "user":
        clean_dict_helper(bot_user_helper(message["user"]))
        if message.get("user") else None,
        "id":
        str(message["_id"]),
    }
コード例 #5
0
ファイル: helper.py プロジェクト: yuekaidi/adminhub_backend
def question_helper(question) -> dict:
    # return {
    #     **question,
    #     "id": str(question["_id"]),
    #     "created_by": str(question["created_by"]) if question.get('created_by') else None,
    #     "updated_by": str(question["updated_by"]) if question.get('updated_by') else None,
    #     "answers": clean_dict_helper(question["answers"]) if question.get('answers') else None
    # }
    return clean_dict_helper({
        **question,
        "id": str(question["_id"]),
    })
コード例 #6
0
def broadcast_history_helper(broadcast) -> dict:
    results = {
        **broadcast, "created_by":
        user_basic_information_helper(broadcast["created_by"]),
        "status":
        'Completed' if broadcast["total"] == broadcast["processed"] > 0 else
        ('Sending' if broadcast["total"] > broadcast["processed"] >=
         broadcast["sent"] > 0 else 'Scheduled'),
        "flow":
        format_flow_out(broadcast["flow"]["flow"]),
        "id":
        str(broadcast["_id"]),
        "failed": [
            bot_user_basic_information_helper(user)
            for user in broadcast['failed']
        ],
        "targets": [
            bot_user_basic_information_helper(user)
            for user in broadcast['targets']
        ]
    }
    return clean_dict_helper(results)
コード例 #7
0
ファイル: helper.py プロジェクト: yuekaidi/adminhub_backend
def message_helper(message) -> dict:
    message['type'] = str(FlowTypeEnumOut(message['type']))
    return clean_dict_helper({
        **message,
        "id": str(message["_id"]),
    })
コード例 #8
0
def user_basic_information_helper(user: dict) -> PortalUserBasicSchemaOut:
    results = {
        "username": user["username"],
        "id": str(user["_id"]),
    }
    return clean_dict_helper(results)
コード例 #9
0
def broadcast_template_helper(broadcast_template) -> dict:
    results = {
        **broadcast_template,
        "id": str(broadcast_template["_id"]),
    }
    return clean_dict_helper(results)
コード例 #10
0
def bot_helper(bot):
    results = {
        **bot,
        "id": str(bot["_id"]),
    }
    return clean_dict_helper(results)