コード例 #1
0
            None, None, None,
            "SET previous_cell_id=if_not_exists(current_cell_id,0);current_cell_id="
            + cell_id +
            ";change_cell_id_indicator=(previous_cell_id != current_cell_id);",
            None)

        if res.status_code not in (200, 204):
            print("Error during update of passengers table. Error code is " +
                  str(res.status_code))

# Get current and previous cell for passenger
        response_json = igz_nosql_web.ngx_get_item_request(
            s,
            WEBAPI_URL,
            PASSENGERS_TABLE_PATH + "passenger_" + passenger_id,
            None,
            None,
            exp_attrs=[
                "change_cell_id_indicator", "current_cell_id",
                "previous_cell_id"
            ])

        # Check if a cell update is needed
        attrs = response_json["Item"]
        change_cell_id_indicator_val = attrs["change_cell_id_indicator"][
            "BOOL"]
        current_cell_id_val = attrs["current_cell_id"]["N"]
        previous_cell_id_val = attrs["previous_cell_id"]["N"]
        #for key, value in attrs.items():
        #     print("attr: {}, value: {}".format(key, value["N"]))

        # Try to increase the count on the cell the driver moved to
コード例 #2
0
        # update driver current and previous location 
        res = igz_nosql_web.ngx_update_expression_request(s,BASE_URL, DRIVERS_PATH_IN_URL + "driver_" + driver_id, None, None,
                                            "CreateOrReplaceAttributes",
                                            "previous_cell_id=current_cell_id;current_cell_id=" + cell_id + ";change_cell_id_indicator=(previous_cell_id != current_cell_id);",
                                            "exists(current_cell_id)")
	
        # if driver does not exist, add driver
	if res.status_code == requests.codes.bad_request:
            igz_nosql_web.ngx_update_expression_request(s,BASE_URL, DRIVERS_PATH_IN_URL + "driver_" + driver_id, None, None,
                                          "CreateOrReplaceAttributes",
                                          "current_cell_id=" + cell_id + ";previous_cell_id=0;change_cell_id_indicator=(1==1);",
                                          "(1==1)")

        # Get current and previous cell for driver 
        response_json = igz_nosql_web.ngx_get_item_request(s,BASE_URL, DRIVERS_PATH_IN_URL+"driver_"+driver_id,None,None,exp_attrs=["change_cell_id_indicator","current_cell_id","previous_cell_id"])

        # Check if a cell update is needed
        attrs = response_json["Item"]
        change_cell_id_indicator_val = attrs["change_cell_id_indicator"]["BOOL"]
        current_cell_id_val = attrs["current_cell_id"]["N"]
        previous_cell_id_val = attrs["previous_cell_id"]["N"]
        #for key, value in attrs.items():
        #     print("attr: {}, value: {}".format(key, value["N"]))

        # Try to increase the count on the cell the driver moved to
        if change_cell_id_indicator_val:
            res=igz_nosql_web.ngx_update_expression_request(s,BASE_URL, CELLS_PATH_IN_URL + "cell_"+ current_cell_id_val, None, None,
                                          "CreateOrReplaceAttributes",
                                          "count=count+1;",
                                          "exists(count)")