Skip to content

Commit 36fa01d

Browse files
authored
Merge pull request #73 from gwu-libraries/frontend-rework
Frontend rework
2 parents ddd5ef3 + 217d2ae commit 36fa01d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1162
-22450
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545

4646
/rails/node_modules
4747

48+
/node_modules
49+
4850
# -- React --
4951
/react/dist
5052

docker-compose.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ services:
1010
POSTGRES_DB: bookworm_production
1111
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
1212
healthcheck:
13-
test: [ "CMD-SHELL", "pg_isready -d bookworm_production -U postgres" ]
13+
test: [ "CMD-SHELL", "pg_isready -d bookworm_production -U bookworm" ]
1414
interval: 10s
1515
timeout: 5s
1616
retries: 10
17+
networks:
18+
- bookworm
19+
hostname: db
1720
rails:
21+
hostname: rails
1822
build: ./rails
1923
container_name: bookworm-rails
2024
command: "bundle exec rails s -p 3001 -b '0.0.0.0'"
@@ -34,20 +38,24 @@ services:
3438
depends_on:
3539
db:
3640
condition: service_healthy
41+
networks:
42+
- bookworm
43+
3744
react:
3845
build: ./react
3946
container_name: bookworm-react
4047
env_file: .env
4148
environment:
4249
NODE_ENV: production
4350
RAILS_API_URL: $RAILS_API_URL
44-
ports:
45-
- 3000:80
4651
healthcheck:
4752
test: [ "CMD-SHELL", "wget --no-verbose --spider --tries=1 localhost:3000 || exit 1" ]
4853
interval: 10s
4954
timeout: 5s
5055
retries: 10
56+
hostname: bookworm-react
57+
networks:
58+
- bookworm
5159
depends_on:
5260
db:
5361
condition: service_healthy
@@ -68,9 +76,10 @@ services:
6876
condition: service_healthy
6977
react:
7078
condition: service_healthy
79+
networks:
80+
- bookworm
7181

7282
volumes:
7383
postgres_data: {}
7484
networks:
75-
default:
76-
name: bookworm
85+
bookworm:

nginx/conf.d/bookworm-ssl.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
server {
2-
listen 443;
2+
listen 443 ssl;
33
server_name bookworm;
44

55
ssl_certificate /etc/ssl/certificate.pem;
66
ssl_certificate_key /etc/ssl/key.pem;
77

88
location /graphql {
9-
proxy_pass http://bookworm-rails:3001/graphql;
9+
proxy_pass http://rails:3001/graphql;
1010
proxy_redirect default;
1111
proxy_http_version 1.1;
1212

nginx/conf.d/bookworm.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ server {
33
server_name bookworm;
44

55
location /graphql {
6-
proxy_pass http://bookworm-rails:3001/graphql;
6+
proxy_pass http://rails:3001/graphql;
77
proxy_redirect default;
88
proxy_http_version 1.1;
99

rails/app/graphql/book_worm_schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
class BookWormSchema < GraphQL::Schema
4-
mutation(Types::MutationType)
4+
# mutation(Types::MutationType)
55
query(Types::QueryType)
66

77
# For batch-loading (see https://graphql-ruby.org/dataloader/overview.html)

rails/app/graphql/types/author_type.rb

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,34 @@ def works
1717
object.works
1818
end
1919

20-
field :authors_ids, Types::AuthorsIdsType
21-
def authors_ids
22-
object.authors_ids
20+
field :datasets, [Types::WorkType]
21+
def datasets
22+
object.works.where(work_type: "dataset")
23+
end
24+
25+
field :articles, [Types::WorkType]
26+
def articles
27+
object.works.where(work_type: "article")
28+
end
29+
30+
field :scopus, String
31+
def scopus
32+
object.authors_ids.scopus
33+
end
34+
35+
field :wikipedia, String
36+
def wikipedia
37+
object.authors_ids.wikipedia
38+
end
39+
40+
field :mag, String
41+
def mag
42+
object.authors_ids.mag
2343
end
2444

2545
field :institutions, [Types::InstitutionType]
2646
def institutions
2747
object.institutions.uniq # move this to the Author model probably
2848
end
29-
30-
field :authors_counts_by_year, [Types::AuthorsCountsByYearType]
31-
def authors_counts_by_year
32-
object.authors_counts_by_year
33-
end
3449
end
3550
end

rails/app/graphql/types/authors_counts_by_year_type.rb

Lines changed: 0 additions & 14 deletions
This file was deleted.

rails/app/graphql/types/authors_ids_type.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

rails/app/graphql/types/institution_type.rb

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,53 @@ class InstitutionType < Types::BaseObject
2020
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
2121

2222
field :authors, [Types::AuthorType]
23-
2423
def authors
25-
object.authors
24+
object.authors.uniq
25+
end
26+
27+
field :wikidata, String
28+
def wikidata
29+
object.institutions_ids.wikidata
30+
end
31+
32+
field :wikipedia, String
33+
def wikipedia
34+
object.institutions_ids.wikipedia
35+
end
36+
37+
field :mag, String
38+
def mag
39+
object.institutions_ids.mag
40+
end
41+
42+
field :grid, String
43+
def grid
44+
object.institutions_ids.grid
45+
end
46+
47+
field :city, String
48+
def city
49+
object.institutions_geo.city
50+
end
51+
52+
field :region, String
53+
def region
54+
object.institutions_geo.region
55+
end
56+
57+
field :country, String
58+
def country
59+
object.institutions_geo.country
60+
end
61+
62+
field :latitude, Float
63+
def latitude
64+
object.institutions_geo.latitude
65+
end
66+
67+
field :longitude, Float
68+
def longitude
69+
object.institutions_geo.longitude
2670
end
2771
end
2872
end

rails/app/graphql/types/institutions_counts_by_year_type.rb

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)