https://github.com/getredash/redash/blob/master/redash/models/init.py#L279

I think there is unnecessary extra request to DB. DataSource has access to groups via back_populates data_source_groups from DataSourceGroup. So, method can be like this:

@property
    def groups(self):
        return dict([(group.group_id, group.view_only) for group in self.data_source_groups]
1 Like