These are chat archives for getredash/redash

21st
Nov 2016
Allen Short
@washort
Nov 21 2016 16:40
@arikfr Trying to understand DataSourceGroup. Can a data source be associated with more than one group? I assumed the answer was 'yes' but it looks like DataSource.data_source_groups only refers to last one added
Arik Fraimovich
@arikfr
Nov 21 2016 16:41
@washort the answer is yes. Why do you assume that?
Allen Short
@washort
Nov 21 2016 16:45
because of how data_source_groups is used in DataSource.add_group and to_dict
.update_group_permission too
Arik Fraimovich
@arikfr
Nov 21 2016 16:46
(going to look at the code)
Arik Fraimovich
@arikfr
Nov 21 2016 16:52
it's embrassing, but I don't fully remember why I did that :flushed: but I believe it was just a hack to pass the object to the API. I don't understand why I didn't use the return value of add_group and manually applied it to the result of to_dict in the handler code. very ugly.
Allen Short
@washort
Nov 21 2016 16:53
OK. I thought this might have just been an oversight, but wanted to be sure :)
Arik Fraimovich
@arikfr
Nov 21 2016 16:53
you're welcome to do this change or I will, and let's both of us forget we ever saw this :worried:
Allen Short
@washort
Nov 21 2016 16:55
Shouldn't be too hard to straighten out. The idea is that to_dict should give the view_only value for the group the requesting user is in?
Arik Fraimovich
@arikfr
Nov 21 2016 16:56
nope, I think it's for the group the request refers to or something of that sort :|
Allen Short
@washort
Nov 21 2016 16:56
mm, ok
oh, these are all in groups API. Got it.
so with_permissions=bool should become with_permissions_for=Group
washort @washort runs tests since CircleCI seems to be on vacation :)
Allen Short
@washort
Nov 21 2016 17:13
getredash/redash#1418
Arik Fraimovich
@arikfr
Nov 21 2016 17:39
On the way home. I'll check it out later today 👍
Allen Short
@washort
Nov 21 2016 17:45
no worries
Eric Feng
@ehfeng
Nov 21 2016 20:47
Hi everyone, question about the python query runner
trying to get datetime to work. we've added datetime as a supported import module
but when i try to use datetime.datetime.strptime
I get '_strptime' is not configured as a supported import module
Arik Fraimovich
@arikfr
Nov 21 2016 20:48
@ehfeng why do you need strptime? For the json dumping?
Eric Feng
@ehfeng
Nov 21 2016 20:49
execute_query's column type is 'datetime', but the actual value is unicode
datetime.datetime.now() - results['rows'][0]['date_added']
results in typeerrors
unsupported operand type(s) for -: 'datetime.datetime' and 'unicode'
Arik Fraimovich
@arikfr
Nov 21 2016 20:51

ok, I see. I looked at the code, and you will need to replace json.dumps on line 231 to json_dumps from redash.utils once you get this working.

as for your actual issue: can you paste an example query I can try?

Eric Feng
@ehfeng
Nov 21 2016 20:51
oh ok
import datetime
q = execute_query('sentry', 'select date_added from sentry_organization limit 1')
print datetime.datetime.now() - q['rows'][0]['date_added']
hm..why isn't the redash.utils.json_dumps the default behavior?
we can change on our end, i'm just curious
Arik Fraimovich
@arikfr
Nov 21 2016 20:55
what do you mean by default?
Eric Feng
@ehfeng
Nov 21 2016 20:56
i guess, why not just use redash.utils.json_dumps at line 231
Arik Fraimovich
@arikfr
Nov 21 2016 20:56
oh, yes, we definitely should. it just something we missed.
Eric Feng
@ehfeng
Nov 21 2016 20:56
ah cool
should i just open up a PR then? we'd like to stay running off redash master if possible :)
Arik Fraimovich
@arikfr
Nov 21 2016 20:58
yep :)
Eric Feng
@ehfeng
Nov 21 2016 20:58
lol small PR ever
Arik Fraimovich
@arikfr
Nov 21 2016 20:58
yes, you can probably do with GitHub's editor :)
I managed to reproduce, but going on a call in a minute. Will continue when I'm back.
Arik Fraimovich
@arikfr
Nov 21 2016 22:02
@ehfeng just add _strptime to the list of allowed modules and it will work :-)