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

setEntitySlot could be better about avoiding unnecessary PATCHes #579

Open
gergness opened this issue Aug 11, 2021 · 0 comments
Open

setEntitySlot could be better about avoiding unnecessary PATCHes #579

gergness opened this issue Aug 11, 2021 · 0 comments

Comments

@gergness
Copy link
Contributor

In investigating #578, I noticed that setting category names to their existing names still results in a PATCH.

httr::with_verbose(categories(ds$test_cat1) <- categories(ds$test_cat1))
#> -> PATCH /api/datasets/8e6c08d6a6d4409fb3b13019d72ca258/variables/d96073d986174f6995611111da436654/ HTTP/2
#> -> Host: app.crunch.io
#> -> Accept-Encoding: deflate, gzip
#> -> Accept: application/json, text/xml, application/xml, */*
#> -> Authorization: Bearer <REDACTED>
#> -> user-agent: libcurl/7.64.1 curl/4.3.2 httr/1.4.2 rcrunch/1.28.1 token
#> -> Content-Length: 241
#> -> 
#> >> {"categories":[{"id":1,"missing":false,"name":"o","numeric_value":1},{"id":2,"missing":false,"name":"p","numeric_value":2},{"id":3,"missing":false,"name":"q","numeric_value":3},{"id":-1,"missing":true,"name":"No Data","numeric_value":null}]}
#> 
#> <- HTTP/2 204 
#> <- date: Wed, 11 Aug 2021 19:05:55 GMT
#> <- location: https://app.crunch.io/api/datasets/8e6c08d6a6d4409fb3b13019d72ca258/variables/d96073d986174f6995611111da436654/
#> <- server: nginx
#> <- allow: DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT
#> <- vary: Cookie, Accept-Encoding
#> <- x-xss-protection: 1; mode=block
#> <- strict-transport-security: max-age=31536000; includeSubDomains
#> <- x-content-type-options: nosniff
#> <- 

The problem is that when checking if they're the same: https://github.com/Crunch-io/rcrunch/blob/master/R/shoji.R#L72

The value on the VariableEntity is a regular R list but the value argument is a true Categories S4 object. Not sure whether it'd be better to make a new function that does the comparison but adapts the classes for you, or if the VariableEntity could be changed so that it had the actual categories on them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant