Skip to content

Commit

Permalink
Merge pull request #15767 from CartoDB/feature/ch95768/api-v4-dataset…
Browse files Browse the repository at this point in the history
…s-doesn-t-return-all-shared

api/v4/datasets doesn't return all shared datasets
  • Loading branch information
alasarr authored Jul 30, 2020
2 parents 70a4b18 + 155a5af commit 5db1536
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Development
- Fix wrong popup position, via new internal carto.js version 4.2.2-1 ([CARTO.js#2254](https://github.com/CartoDB/carto.js/pull/2254))
- Modify .gitignore
- Install Carto::Common::Logger with JSON support ([#15762](https://github.com/CartoDB/cartodb/pull/15762))
- Return all shared datasets ([#15767](https://github.com/CartoDB/cartodb/pull/15767))

4.39.0 (2020-07-20)
-------------------
Expand Down
7 changes: 3 additions & 4 deletions app/controllers/carto/api/public/datasets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ class DatasetsController < Carto::Api::Public::ApplicationController
rescue_from Carto::OauthProvider::Errors::ServerError, with: :rescue_oauth_errors

VALID_ORDER_PARAMS = %i(name).freeze

def index
@master_role = @user.api_keys.master.first.db_role
tables = @user.in_database[select_tables_query].all
result = enrich_tables(tables)
total = @user.in_database[count_tables_query].first[:count]
Expand Down Expand Up @@ -99,18 +98,18 @@ def count_tables_query
end

def query
roles_in = @user.db_service.all_user_roles.join("','")
%{
SELECT table_schema, table_name as name,
string_agg(CASE privilege_type WHEN 'SELECT' THEN 'r' ELSE 'w' END,
'' order by privilege_type) as mode
FROM information_schema.role_table_grants
WHERE grantee='#{@master_role}'
WHERE grantee IN ('#{roles_in}')
AND table_schema not in ('cartodb', 'aggregation')
AND grantor!='postgres'
AND privilege_type in ('SELECT', 'UPDATE')
GROUP BY table_schema,  table_name
}.squish

end

def render_paged(result, total)
Expand Down

0 comments on commit 5db1536

Please sign in to comment.