Giter Site home page Giter Site logo

Comments (4)

matbmeijer avatar matbmeijer commented on September 21, 2024

Hi @hannessnogren, my apologies for the late response - I come back to this always when I have time. I will check your issue and come back to you.

from jiragiler.

Dschaykib avatar Dschaykib commented on September 21, 2024

I had the same issue for the duedate.
After looking a bit into your function I found the problem:

Let's say you have two issues and one does not have an duedate (or resolutiondate or any other field). Within JiraJSON2df you check for the format of the field and set is to NA if it is missing. In the next step you use data.table::rbindlist() and here is the error.

The two data.tables are combined, but one has a date column and the other one a logical.

Maybe a solution would be to check all fields and set them to the most used class?

from jiragiler.

Dschaykib avatar Dschaykib commented on September 21, 2024

UPDATE:
I added some data.table::as.data.table and fiexd some issues.

Here is an approach to set columns, that have different classes all to characters:

DT1 <- data.table(VAR1 = "a", VAR2 = as.Date("2020-04-02"))
DT2 <- data.table(VAR1 = "b", VAR2 = NA)
DT3 <- data.table(VAR1 = "c", VAR2 = as.Date("2020-04-02"))

check_dt <- function(input = list()) {
  classes <- lapply(input, function(dt) {
    dt <- data.table::as.data.table(dt)
    as.data.table(t(dt[, sapply(.SD, class), .SDcol = names(dt)]))}
    )
  
  classes_dt <- rbindlist(classes)
  
  idx <- classes_dt[, sapply(.SD, uniqueN), .SDcol = names(classes_dt)] > 1
  
  idx_cols <- names(idx)[idx]
  
  output <- lapply(input, function(dt, idx_cols){
    dt <- data.table::as.data.table(dt)
    these_cols <- intersect(names(dt), idx_cols)
    if (length(these_cols) >0 ) {
      dt[, c(these_cols) := lapply(.SD, as.character), .SDcol = these_cols]
    }
    return(dt)
    },
    idx_cols = idx_cols)
  return(output)
}

rbindlist(check_dt(input = list(DT1, DT2, DT3)))
> out
   VAR1       VAR2
1:    a 2020-04-02
2:    b       <NA>
3:    c 2020-04-02

from jiragiler.

matbmeijer avatar matbmeijer commented on September 21, 2024

Hi @hannessnogren & @Dschaykib, I changed substantially the internals of the package to increase the robustness of the package and to give a better support for JQL fields. With the latest commit 3452c86 Now your queries should work - here an example with the field "resolutiondate":

JiraQuery2R(domain = "https://bitvoodoo.atlassian.net",
            query = "project='CONGRATS'",
            fields = c("resolutiondate")) %>%
  head() %>% knitr::kable()
id self key ID resolutiondate
57849 https://bitvoodoo.atlassian.net/rest/api/latest/issue/57849 CONGRATS-39 1 NA
57848 https://bitvoodoo.atlassian.net/rest/api/latest/issue/57848 CONGRATS-38 2 NA
57847 https://bitvoodoo.atlassian.net/rest/api/latest/issue/57847 CONGRATS-37 3 NA
57810 https://bitvoodoo.atlassian.net/rest/api/latest/issue/57810 CONGRATS-36 4 2019-10-29 09:32:08
57667 https://bitvoodoo.atlassian.net/rest/api/latest/issue/57667 CONGRATS-32 5 2019-09-23 16:33:36
57502 https://bitvoodoo.atlassian.net/rest/api/latest/issue/57502 CONGRATS-30 6 2019-05-20 09:00:11

@Dschaykib - I tried your commit, and while it solved some of the issues (it did not work always), I preferred to rethink the internal logic instead of repatching the issue. But thank you very much for your help, it helped me quite a lot.

from jiragiler.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.