diff --git a/public/index.html b/public/index.html index 3c3b31c..62dd189 100644 --- a/public/index.html +++ b/public/index.html @@ -188,8 +188,9 @@ before the comment was made. -
{
- "1234": {
+ [
+ {
+ "id": "1234",
"files": {
"src/Main.java": "public class Main { ... }"
},
@@ -197,7 +198,7 @@
"src/Main.java": "@@ -1,3 +1,6 @@ ..."
}
}
-}
+]
{
- "5678": {
+ [
+ {
+ "id": "5678",
"files": { ... },
"diffs": { ... },
"comments": [
{
"body": "Consider simplifying this logic.",
"file": "src/Util.java",
- "location": {
- "start_line": 42,
- "end_line": 45
- }
+ "from_": 42,
+ "to": 45
}
]
}
-}
+]
- All fields are required and must follow the expected types exactly. The line_to
+ All fields are required and must follow the expected types exactly. The from_
field can be null if the comment applies to a single line.
{
"1234": {
"path": "src/Main.java",
- "line_from": 10,
- "line_to": 12,
+ "from_": 10,
+ "to": 12,
"body": "Consider extracting this block into a separate method."
},
"5678": {
"path": "src/Util.java",
- "line_from": 42,
- "line_to": null,
+ "from_": null,
+ "to": 42,
"body": "You might want to add a null check here."
}
}
diff --git a/src/utils/dataset.py b/src/utils/dataset.py
index 8d72e87..5d6250e 100644
--- a/src/utils/dataset.py
+++ b/src/utils/dataset.py
@@ -51,8 +51,8 @@ class Metadata:
@dataclass
class CommentGenSubmission:
path: str
- line_from: int
- line_to: Optional[int]
+ from_: Optional[int]
+ to: int
body: str
@classmethod
@@ -61,15 +61,13 @@ class CommentGenSubmission:
raise InvalidJsonFormatError("Submitted json doesn't contain an object")
if not all(k in data and isinstance(data[k], str) for k in ["path", "body"]):
raise InvalidJsonFormatError("Submitted json doesn't contain the required fields")
- if not all(
- k in data and isinstance(data[k], (int, type(None))) for k in ["line_from", "line_to"]
- ):
+ if not all(k in data and isinstance(data[k], (int, type(None))) for k in ["from_", "to"]):
raise InvalidJsonFormatError("Submitted json doesn't contain the required fields")
return cls(
path=data["path"],
- line_from=data["line_from"],
- line_to=data.get("line_to"),
+ from_=data.get("from_"),
+ to=data["to"],
body=data["body"],
)
diff --git a/src/utils/process_data.py b/src/utils/process_data.py
index cf405d1..6f6125d 100644
--- a/src/utils/process_data.py
+++ b/src/utils/process_data.py
@@ -13,7 +13,7 @@ ARCHIVES_ROOT = os.environ["ARCHIVES_ROOT"]
def comment_distance(submission: CommentGenSubmission, entry: Comment):
if entry.from_ is None and entry.to is None:
return "NA"
- if submission.line_from is None and submission.line_to is None:
+ if submission.from_ is None and submission.to is None:
return "NA"
# Collapse missing endpoints to the one defined endpoint
@@ -21,8 +21,8 @@ def comment_distance(submission: CommentGenSubmission, entry: Comment):
start1 = entry.from_ if entry.from_ is not None else entry.to
end1 = entry.to if entry.to is not None else entry.from_
# For submission:
- start2 = submission.line_from if submission.line_from is not None else submission.line_to
- end2 = submission.line_to if submission.line_to is not None else submission.line_from
+ start2 = submission.from_ if submission.from_ is not None else submission.to
+ end2 = submission.to if submission.to is not None else submission.from_
# Now both start1,end1 and start2,end2 are non-None
# Normalize in case from > to (just in case):