Bugs are now filed with their position information, and loaded into Godot with their proper positions intact.

This commit is contained in:
Jamie Greunbaum
2024-05-26 02:32:55 -04:00
parent 5b4dc53a62
commit ded09a8fa8
6 changed files with 109 additions and 67 deletions
+2 -1
View File
@@ -6,7 +6,8 @@ var title : String
var body : String
var component : StringName
var map_name : StringName
var marker_location : StringName
var marker_position : Vector3
var marker_normal : Vector3
var platform : StringName
var operating_system : StringName
var is_open : bool
+9 -8
View File
@@ -11,7 +11,7 @@ func _init():
__bugbot_server_thread = Thread.new()
func _return_list_of_bugs(callback:Callable) -> int:
func _return_list_of_bugs(map_name:String, callback:Callable) -> int:
print("Insert list of ", _current_server_api(), " bugs here.")
return BugbotServerError.OK
@@ -19,7 +19,7 @@ func _prepare_form(callback:Callable) -> int:
print("Prepare ", _current_server_api(), " form here.")
return BugbotServerError.OK
func _send_form_data(data:Dictionary, callback:Callable) -> int:
func _send_form_data(data:Dictionary, map_name:String, bug_position:Vector3, bug_normal:Vector3, callback:Callable) -> int:
print("Send ", _current_server_api(), " form data here.")
return BugbotServerError.OK
@@ -31,11 +31,6 @@ static func _create_new_server_api() -> BugbotServerAPI:
BugReportPlatform.JIRA: return BugbotServerAPI.new()
return BugbotServerAPI.new()
static func _hide_markers(marker_root:Node):
var markers : Array = marker_root.get_children()
for marker:Node3D in markers:
marker.queue_free()
func __connect_to_server(http_client:HTTPClient, default_server:String) -> int:
var full_server : String = ProjectSettings.get_setting("bugbot/reporting/gitea/server", default_server)
@@ -84,5 +79,11 @@ func __create_header_data(content_length:int = -1) -> Array:
return []
func __return_list_of_bugs_thread(callback:Callable) -> void:
func __return_list_of_bugs_thread(map_name:String, callback:Callable) -> void:
pass
func __prepare_form_thread(callback:Callable) -> void:
pass
func __send_form_data_thread(data:Dictionary, map_name:String, bug_position:Vector3, bug_normal:Vector3, callback:Callable) -> void:
pass
+36 -17
View File
@@ -21,17 +21,17 @@ const RESOLVED_TAG : StringName = &"Status/Resolved"
#endregion
func _return_list_of_bugs(callback:Callable) -> int:
return __start_thread_with_callback(__return_list_of_bugs_thread.bind(callback))
func _return_list_of_bugs(map_name:String, callback:Callable) -> int:
return __start_thread_with_callback(__return_list_of_bugs_thread.bind(map_name, callback))
func _prepare_form(callback:Callable) -> int:
return __start_thread_with_callback(__prepare_form_thread.bind(callback))
func _send_form_data(data:Dictionary, callback:Callable) -> int:
return __start_thread_with_callback(__send_form_data_thread.bind(data, callback))
func _send_form_data(data:Dictionary, map_name:String, bug_position:Vector3, bug_normal:Vector3, callback:Callable) -> int:
return __start_thread_with_callback(__send_form_data_thread.bind(data, map_name, bug_position, bug_normal, callback))
func __return_list_of_bugs_thread(callback:Callable) -> void:
func __return_list_of_bugs_thread(map_name:String, callback:Callable) -> void:
var http_client : HTTPClient = HTTPClient.new()
if __connect_to_server(http_client, DEFAULT_SERVER) != HTTPClient.STATUS_CONNECTED:
printerr("Could not connect to server.")
@@ -61,8 +61,23 @@ func __return_list_of_bugs_thread(callback:Callable) -> void:
var show_unresolved : bool = ProjectSettings.get_setting("bugbot/markers/unresolved/show_unresolved_bugs")
for bug_in:Dictionary in response_data:
var bugbot_marker_string : String = bug_in["body"].split("\n")[-1]
if not bugbot_marker_string.begins_with("{") and not bugbot_marker_string.ends_with("}"):
continue
var bug : BugbotBugData = BugbotBugData.new()
# Check if the map name is valid for the scene we're in.
var bugbot_marker_data : Dictionary = JSON.parse_string(bugbot_marker_string)
bug.map_name = bugbot_marker_data["map_name"]
if bug.map_name != map_name:
continue
var marker_location : Array = bugbot_marker_data["bug_location"]
var marker_normal : Array = bugbot_marker_data["bug_normal"]
bug.marker_position = Vector3(marker_location[0], marker_location[1], marker_location[2])
bug.marker_normal = Vector3(marker_normal[0], marker_normal[1], marker_normal[2])
var bug_labels : Array = []
var resolved_tag_found : bool = false
var in_progress_tag_found : bool = false
@@ -93,7 +108,8 @@ func __return_list_of_bugs_thread(callback:Callable) -> void:
elif unresolved_tag_found or unresolved_labels.is_empty():
bug.resolution = UNRESOLVED_TAG
show_marker = show_unresolved
if not show_marker: continue
if not show_marker:
continue
bug.id = bug_in["id"]
bug.title = bug_in["title"]
@@ -104,8 +120,6 @@ func __return_list_of_bugs_thread(callback:Callable) -> void:
bug.severity = "Severity will go here."
bug.status = bug_in["state"]
bug.duplicate_of = -1
bug.map_name = "Map name will go here."
bug.marker_location = "Marker location will go here."
bug_array.append(bug)
@@ -169,12 +183,13 @@ func __prepare_form_thread(callback:Callable) -> void:
callback.call_deferred(tag_lists)
__bugbot_server_thread.call_deferred("wait_to_finish")
func __send_form_data_thread(data:Dictionary, callback:Callable) -> void:
func __send_form_data_thread(data:Dictionary, map_name:String, bug_position:Vector3, bug_normal:Vector3, callback:Callable) -> void:
var http_client : HTTPClient = HTTPClient.new()
if __connect_to_server(http_client, DEFAULT_SERVER) != HTTPClient.STATUS_CONNECTED:
printerr("Could not connect to server.")
return
# Get a list of available labels to apply to the issue
var api_url : String = __build_url_string("labels")
var header_data : Array = __create_header_data()
var error : int = http_client.request(HTTPClient.METHOD_GET, api_url, header_data)
@@ -182,12 +197,11 @@ func __send_form_data_thread(data:Dictionary, callback:Callable) -> void:
while http_client.get_status() == HTTPClient.STATUS_REQUESTING:
http_client.poll()
assert(http_client.get_status() == HTTPClient.STATUS_BODY or http_client.get_status() == HTTPClient.STATUS_CONNECTED)
var response_string : String = __get_http_client_chunk_response(http_client)
var response_data := JSON.parse_string(response_string)
var response_data : Variant = JSON.parse_string(__get_http_client_chunk_response(http_client))
if __validate_server_response(response_data) != Error.OK:
return
# Collect the label IDs for each label we want to apply to this issue
var labels : Array
var bug_label : String = ProjectSettings.get_setting("bugbot/reporting/gitea/bug_label", DEFAULT_BUG_LABEL)
var status_label : String = ProjectSettings.get_setting("bugbot/reporting/gitea/default_status_label", DEFAULT_STATUS_LABEL)
@@ -196,6 +210,9 @@ func __send_form_data_thread(data:Dictionary, callback:Callable) -> void:
labels.append(label_in["id"])
(data["labels"] as Array).append_array(labels)
data["body"] += "\n\n" + """{ "map_name": "%s", "bug_position": [%.4f, %.4f, %.4f], "bug_normal": [%.4f, %.4f, %.4f] }""" % [map_name, bug_position.x, bug_position.y, bug_position.z, bug_normal.x, bug_normal.y, bug_normal.z]
# Post issue to Gitea
api_url = __build_url_string("issues")
var post_data_string : String = JSON.stringify(data)
header_data = __create_header_data(post_data_string.length())
@@ -204,9 +221,11 @@ func __send_form_data_thread(data:Dictionary, callback:Callable) -> void:
while http_client.get_status() == HTTPClient.STATUS_REQUESTING:
http_client.poll()
assert(http_client.get_status() == HTTPClient.STATUS_BODY or http_client.get_status() == HTTPClient.STATUS_CONNECTED)
response_string = __get_http_client_chunk_response(http_client)
var post_response_data : Variant = JSON.parse_string(__get_http_client_chunk_response(http_client))
if __validate_server_response(post_response_data) != Error.OK:
return
callback.call_deferred(JSON.parse_string(response_string))
callback.call_deferred(post_response_data)
__bugbot_server_thread.call_deferred("wait_to_finish")
@@ -234,9 +253,9 @@ func __create_header_data(content_length:int = -1) -> Array:
return header
func __validate_server_response(_response:Variant) -> int:
# If the response is a dictionary and not an array, make the assumption
# that this is because the response was an error code.
if _response is Dictionary:
# If the response has a message field, make the assumption that this is
# because the response was an error code.
if _response.has("message"):
var error_data : BugbotErrorData = BugbotErrorData.new()
error_data.code = 1
error_data.message = _response["message"]