Skip to content

Commit f492c7b

Browse files
committed
small bug fixes
1 parent c63171c commit f492c7b

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

R/check_existing_item.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ check_existing_item <- function(search_term,
9595
logical(1)
9696
)
9797

98+
if (!is.logical(exact_match)) message (matching_props[exact_match])
99+
98100
if (sum(exact_match) > 1) {
99-
stop("Multiple items [", paste(matching_items, collapse = ", "), "] are matching '", search_term, "' in language='", language, "'.")
101+
stop("Multiple items [", paste(matching_items, collapse = ", "),
102+
"] are matching '", search_term, "' in language='", language, "'.")
100103
}
101104

102105
if (!any(exact_match)) {
@@ -121,7 +124,9 @@ check_existing_item <- function(search_term,
121124
action = action,
122125
id_on_target = matching_item_data$id,
123126
label = matching_item_data$label,
124-
description = ifelse(is.null(matching_item_data$description), "", matching_item_data$description),
127+
description = ifelse(is.null(matching_item_data$description),
128+
"",
129+
matching_item_data$description),
125130
language = language,
126131
datatype = "wikibase-item",
127132
wikibase_api_url = wikibase_api_url,

R/check_existing_property.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ check_existing_property <- function(
9797
logical(1)
9898
)
9999

100+
if (!is.logical(exact_match)) message (matching_props[exact_match])
101+
100102
if (sum(exact_match) > 1) {
101103
stop("Multiple items [", paste(matching_props, collapse = ", "), "] are matching '", search_term, "' in language='", language, "'.")
102104
}
@@ -118,7 +120,8 @@ check_existing_property <- function(
118120

119121
matching_property_data <- search_response$search[[which(exact_match)]]
120122

121-
comment_text <- glue::glue("A property with the label ", search_term, " already exists in this Wikibase.")
123+
comment_text <- glue::glue("A property with the label ",
124+
search_term, " already exists in this Wikibase.")
122125

123126
return_dataframe <- data.frame(
124127
action = action,
@@ -204,7 +207,8 @@ check_existing_property <- function(
204207
"wd:", "wbi:"
205208
)
206209

207-
return_ds$rowid <- defined(paste0(prefix, as.character(return_ds$id_on_target)),
210+
return_ds$rowid <- defined(paste0(prefix,
211+
as.character(return_ds$id_on_target)),
208212
namespace = wikibase_api_url
209213
)
210214

R/create_item.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ create_item <- function(label,
191191
msg = "You do not have a CSRF token"
192192
)
193193

194-
assertthat::assert_that(nchar(csrf_token) == 42,
195-
msg = "Your CSRF token should have 42 characters."
194+
assertthat::assert_that(nchar(csrf_token) > 10,
195+
msg = "Your CSRF token usually should have 42 characters."
196196
)
197197

198198
# Posting the new property ----------------------------------------------

R/create_property.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,20 @@ create_property <- function(label,
235235
}
236236

237237
new_description_text <- ""
238-
new_descriptions <- created_item_response$entity$descriptions
238+
new_descriptions <- created_property_response$entity$descriptions
239+
239240
if ( length(new_descriptions)==0 ) {
240241
new_description_text <- ""
241242
} else {
242-
new_description_text <- created_item_response$entity$descriptions[[1]]$language
243+
new_description_text <- created_property_response$entity$descriptions[[1]]$language
243244
}
244245

245246
return_dataframe <- data.frame(
246247
action = "create_property",
247248
id_on_target = created_property_response$entity$id,
248249
label = label,
249250
description = new_description_text,
250-
language = created_item_response$entity$labels[[1]]$language,
251+
language = created_property_response$entity$labels[[1]]$language,
251252
datatype = created_property_response$entity$datatype,
252253
wikibase_api_url = wikibase_api_url,
253254
equivalence_property = equivalence_property,

0 commit comments

Comments
 (0)