Skip to content

Commit

Permalink
Merge pull request #73 from gwu-libraries/frontend-rework
Browse files Browse the repository at this point in the history
Frontend rework
  • Loading branch information
alepbloyd authored Jan 30, 2025
2 parents ddd5ef3 + 217d2ae commit 36fa01d
Show file tree
Hide file tree
Showing 56 changed files with 1,162 additions and 22,450 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

/rails/node_modules

/node_modules

# -- React --
/react/dist

Expand Down
19 changes: 14 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ services:
POSTGRES_DB: bookworm_production
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d bookworm_production -U postgres" ]
test: [ "CMD-SHELL", "pg_isready -d bookworm_production -U bookworm" ]
interval: 10s
timeout: 5s
retries: 10
networks:
- bookworm
hostname: db
rails:
hostname: rails
build: ./rails
container_name: bookworm-rails
command: "bundle exec rails s -p 3001 -b '0.0.0.0'"
Expand All @@ -34,20 +38,24 @@ services:
depends_on:
db:
condition: service_healthy
networks:
- bookworm

react:
build: ./react
container_name: bookworm-react
env_file: .env
environment:
NODE_ENV: production
RAILS_API_URL: $RAILS_API_URL
ports:
- 3000:80
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --spider --tries=1 localhost:3000 || exit 1" ]
interval: 10s
timeout: 5s
retries: 10
hostname: bookworm-react
networks:
- bookworm
depends_on:
db:
condition: service_healthy
Expand All @@ -68,9 +76,10 @@ services:
condition: service_healthy
react:
condition: service_healthy
networks:
- bookworm

volumes:
postgres_data: {}
networks:
default:
name: bookworm
bookworm:
4 changes: 2 additions & 2 deletions nginx/conf.d/bookworm-ssl.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
server {
listen 443;
listen 443 ssl;
server_name bookworm;

ssl_certificate /etc/ssl/certificate.pem;
ssl_certificate_key /etc/ssl/key.pem;

location /graphql {
proxy_pass http://bookworm-rails:3001/graphql;
proxy_pass http://rails:3001/graphql;
proxy_redirect default;
proxy_http_version 1.1;

Expand Down
2 changes: 1 addition & 1 deletion nginx/conf.d/bookworm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ server {
server_name bookworm;

location /graphql {
proxy_pass http://bookworm-rails:3001/graphql;
proxy_pass http://rails:3001/graphql;
proxy_redirect default;
proxy_http_version 1.1;

Expand Down
2 changes: 1 addition & 1 deletion rails/app/graphql/book_worm_schema.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class BookWormSchema < GraphQL::Schema
mutation(Types::MutationType)
# mutation(Types::MutationType)
query(Types::QueryType)

# For batch-loading (see https://graphql-ruby.org/dataloader/overview.html)
Expand Down
31 changes: 23 additions & 8 deletions rails/app/graphql/types/author_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,34 @@ def works
object.works
end

field :authors_ids, Types::AuthorsIdsType
def authors_ids
object.authors_ids
field :datasets, [Types::WorkType]
def datasets
object.works.where(work_type: "dataset")
end

field :articles, [Types::WorkType]
def articles
object.works.where(work_type: "article")
end

field :scopus, String
def scopus
object.authors_ids.scopus
end

field :wikipedia, String
def wikipedia
object.authors_ids.wikipedia
end

field :mag, String
def mag
object.authors_ids.mag
end

field :institutions, [Types::InstitutionType]
def institutions
object.institutions.uniq # move this to the Author model probably
end

field :authors_counts_by_year, [Types::AuthorsCountsByYearType]
def authors_counts_by_year
object.authors_counts_by_year
end
end
end
14 changes: 0 additions & 14 deletions rails/app/graphql/types/authors_counts_by_year_type.rb

This file was deleted.

15 changes: 0 additions & 15 deletions rails/app/graphql/types/authors_ids_type.rb

This file was deleted.

48 changes: 46 additions & 2 deletions rails/app/graphql/types/institution_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,53 @@ class InstitutionType < Types::BaseObject
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false

field :authors, [Types::AuthorType]

def authors
object.authors
object.authors.uniq
end

field :wikidata, String
def wikidata
object.institutions_ids.wikidata
end

field :wikipedia, String
def wikipedia
object.institutions_ids.wikipedia
end

field :mag, String
def mag
object.institutions_ids.mag
end

field :grid, String
def grid
object.institutions_ids.grid
end

field :city, String
def city
object.institutions_geo.city
end

field :region, String
def region
object.institutions_geo.region
end

field :country, String
def country
object.institutions_geo.country
end

field :latitude, Float
def latitude
object.institutions_geo.latitude
end

field :longitude, Float
def longitude
object.institutions_geo.longitude
end
end
end
14 changes: 0 additions & 14 deletions rails/app/graphql/types/institutions_counts_by_year_type.rb

This file was deleted.

17 changes: 0 additions & 17 deletions rails/app/graphql/types/institutions_geo_type.rb

This file was deleted.

15 changes: 0 additions & 15 deletions rails/app/graphql/types/institutions_ids_type.rb

This file was deleted.

2 changes: 1 addition & 1 deletion rails/app/graphql/types/mutation_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Types
class MutationType < Types::BaseObject
field :register_user, mutation: Mutations::RegisterUser
# field :register_user, mutation: Mutations::RegisterUser
# field :sign_in, mutation: Mutations::SignIn
# # field :sign_out, mutation: Mutations::SignOut

Expand Down
10 changes: 10 additions & 0 deletions rails/app/graphql/types/publisher_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,15 @@ class PublisherType < Types::BaseObject
field :sources_api_url, String
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false

field :ror, String
def ror
object.publishers_ids.ror
end

field :wikidata, String
def wikidata
object.publishers_ids.wikidata
end
end
end
14 changes: 0 additions & 14 deletions rails/app/graphql/types/publishers_counts_by_year_type.rb

This file was deleted.

12 changes: 0 additions & 12 deletions rails/app/graphql/types/publishers_ids_type.rb

This file was deleted.

12 changes: 11 additions & 1 deletion rails/app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,21 @@ def nodes(ids:)
null: true,
description: 'Fetches an institution by ROR' do
argument :ror, String, required: true
end
end
def institution_by_ror(ror:)
Institution.find_by(ror: ror)
end

field :institution_by_name,
Types::InstitutionType,
null: true,
description: 'Fetches an institution by name' do
argument :name, String, required: true
end
def institution_by_name(name:)
Institution.find_by(display_name: name)
end

# author entry points

field :author_by_openalex_id,
Expand Down
25 changes: 25 additions & 0 deletions rails/app/graphql/types/source_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,30 @@ class SourceType < Types::BaseObject
field :works_api_url, String
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false

field :issn_l, String
def issn_l
object.source_ids.issn_l
end

field :issn, String
def issn
object.sources_ids.issn
end

field :mag, String
def mag
object.sources_ids.mag
end

field :wikidata, String
def wikidata
object.sources_ids.wikidata
end

field :fatcat, String
def fatcat
object.sources_ids.fatcat
end
end
end
14 changes: 0 additions & 14 deletions rails/app/graphql/types/sources_counts_by_year_type.rb

This file was deleted.

Loading

0 comments on commit 36fa01d

Please sign in to comment.