コード例 #1
0
    def process_contact(user_id1, user_id2, relevance_factor):
        logger.info("Processing contact between {} and {} with relevance_factor {}".format(user_id1, user_id2,
                                                                                           relevance_factor))

        risk_level1 = Database.get_users_risk_level(user_id1)
        risk_level2 = Database.get_users_risk_level(user_id2)

        try:
            Database.update_risk_level(user_id2, min(int(risk_level2 + risk_level1 * relevance_factor), 4))
        except Exception as ex:
            logger.error("EXCEPTION DATABASE: {} {}".format(type(ex), ex))
            return ErrorResponse("Database error")
コード例 #2
0
ファイル: core.py プロジェクト: yoshc/corona-tracking-backend
    def _process_get_user_status_request(self, request):
        assert isinstance(request, GetUserStatusRequest)
        logger.debug("PROCESSING UPDATE USER STATUS REQUEST...")

        user_id = request.user_id
        risk_level = None
        try:
            risk_level = Database.get_users_risk_level(user_id)
        except Exception as ex:
            logger.error("EXCEPTION DATABASE: {} {}".format(type(ex), ex))
            return ErrorResponse("Database error")
        return CustomResponse(success=True, message="", status=risk_level)