Skip to content

Commit d641ea1

Browse files
authored
Merge pull request #846 from OpenKnowledgeMaps/dev
refactor: error handling updates
2 parents eddcd13 + 635e755 commit d641ea1

3 files changed

Lines changed: 15 additions & 22 deletions

File tree

examples/public/main_integration/css/main.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,6 +2075,7 @@ a.donation-button:hover, a.donation-button:active, a.donation-button:focus {
20752075

20762076
#error-remedy_list li {
20772077
list-style: disc;
2078+
margin-bottom: 10px;
20782079
}
20792080

20802081
#error-remedy_list {

server/preprocessing/other-scripts/utils.R

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -120,26 +120,17 @@ detect_error <- function(failed, service, params) {
120120
reason <- c(reason, "API error: OpenAIRE not reachable")
121121
}
122122
}
123+
124+
# If not one of the known data source API errors:
125+
# "not enough results" or "timeframe too short" if it was specified
123126
if (length(reason) == 0) {
124-
result <- regmatches(failed$query, regexec(phrasepattern, failed$query))
125-
# if not one of the known data source API errors:
126-
# apply query error detection heuristics
127-
if (grepl('', failed$query, fixed = TRUE) ||
128-
grepl('', failed$query, fixed = TRUE)) {
129-
reason <- c(reason, 'query formatting')
130-
}
131-
if (!identical(result[[1]], character(0)) &&
132-
length(unlist(strsplit(result[[1]][2], " "))) > 4) {
133-
reason <- c(reason, 'too specific')
134-
} else if (length(unlist(strsplit(failed$query, " "))) < 4) {
135-
reason <- c(reason, 'typo', 'too specific')
136-
} else {
137-
reason <- c(reason, 'query length', 'too specific')
138-
}
139-
if (!is.null(failed$params$to) &&
140-
!is.null(failed$params$from) &&
141-
difftime(failed$params$to, failed$params$from) <= 60) {
142-
reason <- c(reason, 'timeframe too short')
127+
has_timeframe <- !is.null(failed$params$to) && !is.null(failed$params$from)
128+
is_short_timeframe <- has_timeframe && difftime(failed$params$to, failed$params$from) <= 60
129+
130+
if (is_short_timeframe) {
131+
reason <- c(reason, 'timeframe too short')
132+
} else {
133+
reason <- c(reason, 'not enough results')
143134
}
144135
}
145136
}

vis/test/component/citationmodal.test.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ const getMockStoreData = (isStreamgraph: boolean) => {
4343
const getCitationText = (isStreamgraph: boolean) => {
4444
const mockStoreData = getMockStoreData(isStreamgraph);
4545
const citationTemplate = mockStoreData.localization.citation_template;
46+
const currentYear = new Date().getFullYear();
4647
const mockCitationStringData = {
47-
year: "2025",
48+
year: String(currentYear),
4849
type: isStreamgraph ? "Streamgraph" : "Knowledge Map",
4950
query: "climate change and impact",
5051
source: "http://localhost:3000/",
@@ -53,7 +54,7 @@ const getCitationText = (isStreamgraph: boolean) => {
5354

5455
return formatString(citationTemplate, mockCitationStringData).replace(
5556
" [].",
56-
"."
57+
".",
5758
);
5859
};
5960

@@ -68,7 +69,7 @@ const setup = (isStreamgraph: boolean) => {
6869
<LocalizationProvider localization={localization}>
6970
<CitationModal />
7071
</LocalizationProvider>
71-
</Provider>
72+
</Provider>,
7273
);
7374
};
7475

0 commit comments

Comments
 (0)