Skip to content

Commit

Permalink
Merge pull request #15 from gwu-libraries/show-abstracts
Browse files Browse the repository at this point in the history
Show abstracts
  • Loading branch information
alepbloyd authored Aug 27, 2024
2 parents 16529d3 + eeaddc9 commit 2af5dec
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 167 deletions.
3 changes: 2 additions & 1 deletion rails/app/graphql/mutations/create_work_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def resolve(**attributes)
keywords: openalex_work.keywords,
topics: openalex_work.topics,
is_open_access: openalex_work.is_open_access,
open_access_url: openalex_work.open_access_url
open_access_url: openalex_work.open_access_url,
abstract: openalex_work.abstract
)

work_node =
Expand Down
1 change: 1 addition & 0 deletions rails/app/graphql/types/work_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class WorkType < Types::BaseObject
field :open_access_url, String
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
field :abstract, String

field :authors, [Types::AuthorType]
field :citations, [Types::WorkType]
Expand Down
15 changes: 14 additions & 1 deletion rails/app/poros/openalex_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class OpenalexWork
:created_date,
:is_open_access,
:open_access_url,
:grants
:grants,
:abstract

def initialize(data)
@openalex_id = data[:ids][:openalex].split("/").last || "Not found"
Expand All @@ -29,6 +30,18 @@ def initialize(data)
@doi = "Not found"
end

if data[:abstract_inverted_index]
uninverted_arr = []

data[:abstract_inverted_index].each do |word, placement_arr|
placement_arr.each do |placement_index|
uninverted_arr[placement_index] = word.to_s
end
end

@abstract = uninverted_arr.join(" ")
end

@title = data[:title] || []

@publication_year = data[:publication_year] || []
Expand Down
1 change: 1 addition & 0 deletions rails/db/migrate/20240418013207_create_works.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def change
t.string :topics, array: true, default: []
t.boolean :is_open_access, default: false
t.string :open_access_url
t.string :abstract, default: ""

t.timestamps
end
Expand Down
1 change: 1 addition & 0 deletions rails/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
t.string "topics", default: [], array: true
t.boolean "is_open_access", default: false
t.string "open_access_url"
t.string "abstract", default: ""
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2af5dec

Please sign in to comment.