Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: replace_publications_in_pub_index_md() behavior changed after cleaning #8

Open
mrustl opened this issue Aug 29, 2020 · 3 comments · Fixed by #6
Open

bug: replace_publications_in_pub_index_md() behavior changed after cleaning #8

mrustl opened this issue Aug 29, 2020 · 3 comments · Fixed by #6
Assignees
Labels
bug Something isn't working

Comments

@mrustl
Copy link
Member

mrustl commented Aug 29, 2020

Cleaning (#6) unfortunately introduced a bug. The function replace_publications_in_pub_index_md() now produces wrong results (content is linked to wrong rec_id and formatting is also not correct, see screenshot for rec_id=1045):
grafik

remotes::install_github("kwb-r/kwb.pubs@4ce47443f1812a96e033d5a927a4b307d2d5617b", upgrade = "always")
kwb.pubs::replace_publications_in_pub_index_md(md_paths = pub_md_paths, 
                                               endnote_db_refs = en_refs)

Data for bug-fixing:

Please fix and verify that publication stays the same for all records!

@mrustl mrustl added the bug Something isn't working label Aug 29, 2020
@mrustl mrustl linked a pull request Aug 29, 2020 that will close this issue
Merged
@hsonne
Copy link
Member

hsonne commented Aug 30, 2020

The problem was not in replace_publications_in_pub_index_md() but in my new function format_given() where I defined the arguments in the wrong order. This affected the content of en_refs when being modified by add_columns_to_endnote_db(). Thus, your uploaded version of en_refs (in en_refs.zip) was already "corrupt". This is fixed now. I used the following script to recreate the md files. However, I get differences due to the fact that I do not have the latest version of the Endnote db (I assume).

remotes::install_github("kwb-r/kwb.pubs@clean", upgrade = "never")

path_en_db <- "<path-to-my-local-endnote-dbs>/KWB-documents_20191205.Data/sdb/sdb.eni"

contents <- kwb.pubs::read_endnote_db(path_en_db)

en_refs <- kwb.pubs::add_columns_to_endnote_db(contents$refs)

en_refs$publication <- stringr::str_replace_all(en_refs$publication, pattern = '"', '\\\\"')
en_refs$publication <- sprintf("\"%s\"", en_refs$publication)

path <- "content/de/publication"
pub_md_paths <- dir(path, "md$", full.names = TRUE, recursive = TRUE)

#kwb.pubs::replace_dates_in_pub_index_md(pub_md_paths, en_refs)
#kwb.pubs::replace_publishdates_in_pub_index_md(pub_md_paths, en_refs)
kwb.pubs::replace_publications_in_pub_index_md(pub_md_paths, en_refs)

Can you do the verification test?

@mrustl
Copy link
Member Author

mrustl commented Aug 30, 2020

I can verify that the issue is fixed now

library(kwb.pubs)
### using en_refs.Rds from zip file (see above)
en_refs <- readRDS("en_refs.Rds") %>% dplyr::select(- publish_datetime, - publication)
en_refs <- kwb.pubs::add_columns_to_endnote_db(en_refs)


en_refs$publication <- stringr::str_replace_all(en_refs$publication, pattern = '"', '\\\\"')
en_refs$publication <- sprintf("\"%s\"", en_refs$publication)

path <- "content/de/publication"
pub_md_paths <- dir(path, "md$", full.names = TRUE, recursive = TRUE)

#kwb.pubs::replace_dates_in_pub_index_md(pub_md_paths, en_refs)
#kwb.pubs::replace_publishdates_in_pub_index_md(pub_md_paths, en_refs)
kwb.pubs::replace_publications_in_pub_index_md(pub_md_paths, en_refs)

Could you add this step to the function kwb.pubs::add_kwb_style() ?

en_refs$publication <- stringr::str_replace_all(en_refs$publication, pattern = '"', '\\\\"')
en_refs$publication <- sprintf("\"%s\"", en_refs$publication)

mrustl added a commit to KWB-R/pubs that referenced this issue Sep 4, 2020
@mrustl
Copy link
Member Author

mrustl commented Sep 4, 2020

Hi @hsonne ,

seems we have one more issue to solve (EN ID: 675, 855,1163, 1164) -> https://github.com/KWB-R/kwb.pubs/files/5145961/en_refs.zip):

grafik

grafik

grafik

Maybe just a different behavior in case of missing data? I think your approach is there better than my simple one before!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants