Skip to content

Commit

Permalink
first bit of reworking the search, and a handy codetable endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jambun committed Jun 14, 2024
1 parent 1588e64 commit 0e1426d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
14 changes: 14 additions & 0 deletions backend/controllers/reftracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ class ArchivesSpaceService < Sinatra::Base
end
end

Endpoint.get('/plugins/reftracker/codetable/:table')
.description("Get a RefTracker code table")
.params(['table', String, 'The code table to get'])
.permissions([])
.returns([200, "codetable"], [404, 'not found']) \
do
begin
# FIXME: came back as a quoted string of json, might need to parse it
json_response(RefTrackerClient.get_codetable(params[:table]))
rescue RecordNotFound => e
json_response({:error => e.message}, 404)
end
end

Endpoint.post('/repositories/:repo_id/reftracker/import/:offer')
.description("Import an Offer from RefTracker as an Accession")
.params(["repo_id", :repo_id],
Expand Down
27 changes: 25 additions & 2 deletions backend/model/reftracker_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,30 @@ def self.closed_offers(page = 1)
'bib_udf_tb03',
'bib_title',
'client_name',
'question_format',
'question_update_datetime',
'question_closed_datetime',
]

# status of 700 is 'Closed successful' found this using /codetable?table=status
# :status => '700' - not doing this any more

# qtype of 100 is 'Offerer service' - new requirement
# db = 5 is a magic number from the original plugin.
# without it the api complains about missing a param called 'source'
# sortby = 3 is ClosedDate

# last update: qnudt - can't sort by this so qno instead
# :sortby => '50' is question_no

# question_format = Manuscripts
# :qnfmid => '10'

search_params = {
:status => '700',
:qtype => '100',
:qnfmid => '10',
:db => '5',
:sortby => '3',
:sortby => '50',
:sortorder => 'DESC',
:columnList => columns.join('|'),
:pagenumber => page,
Expand All @@ -54,6 +65,18 @@ def self.closed_offers(page = 1)
end


# ok now got an endpoint for codetables:
# format is format so:
# /plugins/reftracker/codetable/format
# tells me that format for Manuscripts is 10
def self.get_codetable(table)
search_params = {
:codetable => table,
}
self.get('codetable', {:parameters => search_params.to_json})
end


def self.get(uri, params = {})
url = URI(File.join(AppConfig[:reftracker_base_url], uri))
url.query = URI.encode_www_form(params) unless params.empty?
Expand Down

0 comments on commit 0e1426d

Please sign in to comment.