Skip to content

Commit

Permalink
fix: match the proper json path for website and logo properties
Browse files Browse the repository at this point in the history
  • Loading branch information
shj1081 committed Nov 21, 2024
1 parent 0842843 commit a75347e
Showing 1 changed file with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setProperties(JsonNode properties) {
this.position = extractTextFromProperty(properties, "채용 포지션", "rich_text");
this.logo = extractLogoUrl(properties, "logo");
this.salary = extractTextFromProperty(properties, "연봉", "rich_text");
this.website = extractTextFromProperty(properties, "웹사이트", "url");
this.website = extractUrl(properties, "웹사이트");
this.state = extractMultiSelect(properties, "채용 상태");
this.hiringTime = extractTextFromProperty(properties, "채용 시점", "rich_text");
}
Expand Down Expand Up @@ -99,13 +99,37 @@ private String extractLogoUrl(JsonNode properties, String fieldName) {
if (properties.has(fieldName)) {
JsonNode filesNode = properties.get(fieldName).get("files");
if (filesNode.isArray() && filesNode.size() > 0) {
JsonNode firstFileNode = filesNode.get(0).get("file");
if (firstFileNode != null && firstFileNode.has("url")) {
return firstFileNode.get("url").asText();
JsonNode firstFileNode = filesNode.get(0);

// Handle internal file type
if (firstFileNode.has("file")) {
JsonNode fileNode = firstFileNode.get("file");
if (fileNode != null && fileNode.has("url")) {
return fileNode.get("url").asText();
}
}

// Handle external file type
if (firstFileNode.has("external")) {
JsonNode externalNode = firstFileNode.get("external");
if (externalNode != null && externalNode.has("url")) {
return externalNode.get("url").asText();
}
}
}
}
return null;
}

// Extract url from website property
private String extractUrl(JsonNode properties, String fieldName) {
if (properties.has(fieldName)) {
JsonNode urlNode = properties.get(fieldName).get("url");
if (urlNode != null && !urlNode.isNull()) {
return urlNode.asText();
}
}
return null;
}

}

0 comments on commit a75347e

Please sign in to comment.