Skip to content

Commit

Permalink
show correct aggregate counts for consortium_member. datacite/datacit…
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Aug 7, 2019
1 parent 4648a26 commit 246a492
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ bundle exec rspec
```

Note when using a fresh test database you will need to instantiate the test db with:

```bash
bundle exec rake db:create RAILS_ENV=test
```


Follow along via [Github Issues](https://github.com/datacite/lupo/issues).

### Note on Patches/Pull Requests
Expand Down
22 changes: 20 additions & 2 deletions app/controllers/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def show
providers = provider_count(consortium_id: nil)
clients = client_count(provider_id: nil)
dois = doi_count(provider_id: nil)
elsif @provider.member_type == "consortium"
elsif @provider.member_type == "consortium_member"
providers = provider_count(consortium_id: params[:id])
clients = client_count(consortium_id: params[:id])
dois = doi_count(consortium_id: params[:id])
Expand Down Expand Up @@ -184,9 +184,27 @@ def create
authorize! :create, @provider

if @provider.save
if @provider.symbol == "ADMIN"
providers = provider_count(consortium_id: nil)
clients = client_count(provider_id: nil)
dois = doi_count(provider_id: nil)
elsif @provider.member_type == "consortium_member"
providers = provider_count(consortium_id: params[:id])
clients = client_count(consortium_id: params[:id])
dois = doi_count(consortium_id: params[:id])
else
providers = nil
clients = client_count(provider_id: params[:id])
dois = doi_count(provider_id: params[:id])
end

options = {}
options[:include] = @include
options[:is_collection] = false
options[:meta] = {
providers: providers,
clients: clients,
dois: dois }.compact
options[:params] = { current_ability: current_ability }

render json: ProviderSerializer.new(@provider, options).serialized_json, status: :ok
Expand All @@ -204,7 +222,7 @@ def update
providers = provider_count(consortium_id: nil)
clients = client_count(provider_id: nil)
dois = doi_count(provider_id: nil)
elsif @provider.member_type == "consortium"
elsif @provider.member_type == "consortium_member"
providers = provider_count(consortium_id: params[:id])
clients = client_count(consortium_id: params[:id])
dois = doi_count(consortium_id: params[:id])
Expand Down

0 comments on commit 246a492

Please sign in to comment.