rstudio / rscloud

Managing RStudio Cloud spaces with R
https://rstudio.github.io/rscloud
Other
22 stars 11 forks source link

Additional filters for 'space_member_usage'. #49

Open kputschko opened 3 years ago

kputschko commented 3 years ago

In the help page for the space_member_usage function, I see there is a filters argument that makes use of both groupby and from. I'm wondering if there are any more parameters that could be passed into this filter argument?

kputschko commented 3 years ago

In addition, are there any additional ways to specify the from argument? The help page shows from = "90d", but I'm curious how to further specify a date range of interest.

These work: space_member_usage(space, filters = list(groupby = "user_id", from = "30d")) space_member_usage(space, filters = list(groupby = "user_id", from = "123456789")) (I assume it's milliseconds from 1970-01-01)

But these don't work: space_member_usage(space, filters = list(groupby = "user_id", from = "2021-10-20")) space_member_usage(space, filters = list(groupby = "user_id", from = "1y")) space_member_usage(space, filters = list(groupby = "user_id", from = "1m")) space_member_usage(space, filters = list(groupby = "user_id", from = "1 week"))

And this is the error that is returned:

Error: Request to endpoint `spaces/***/usage` failed with
  Status: 400
  Response: Invalid argument from: is not an ISO datetime type or is not a unix epoch timestamp or is not an ISO date or is not a valid relative date
kputschko commented 2 years ago

I'm running into another issues as of today. This code ran successfully last week.

space_member_usage(space, filters = list(groupby = "user_id", from = "90d"))

But now it is returning this error:

Error: Problem with `mutate()` column `last_activity`.
i `last_activity = as.POSIXct(.data$last_activity/1000, origin = "1970-01-01")`.
x Column `last_activity` not found in `.data`

Interestingly, I can use from = 30, but not from = 35.

# Success
space_member_usage(space, filters = list(groupby = "user_id", from = "30d"))

# Failure
space_member_usage(space, filters = list(groupby = "user_id", from = "35d"))
mine-cetinkaya-rundel commented 2 years ago

@kputschko There was an update in the last week in the API to limit last_activity to 30 days. I'm working on updating the function to reflect this change so the function works for any time period but reports last_activity only up to 30 days and for time periods longer than that it doesn't report it.

kputschko commented 2 years ago

Thanks for the response. To clarify, going forward it will only be possible to look back at time frames within the last 30 days?

mine-cetinkaya-rundel commented 2 years ago

Yes, for the last_active field it will only be possible to look back within the last 30 days. For other fields there won't be such time limit.

mine-cetinkaya-rundel commented 2 years ago

@kputschko The broken space_member_usage() call for longer time periods should now be fixed with #50. Leaving the issue open to remind of the original request re: better documentation of possible filters.