Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple autosuggest results API endpoints #10736

Open
2 tasks
ewhanson opened this issue Dec 18, 2024 · 0 comments
Open
2 tasks

Decouple autosuggest results API endpoints #10736

ewhanson opened this issue Dec 18, 2024 · 0 comments
Assignees
Labels
Enhancement:1:Minor A new feature or improvement that can be implemented in less than 3 days.
Milestone

Comments

@ewhanson
Copy link
Collaborator

ewhanson commented Dec 18, 2024

Describe the issue
The API endpoint that returns controlled vocabulary results and autosuggest results are served by a single end point. These should be decoupled into domain-specific endpoints to reduce complexity of the current single endpoint, e.g. accounting for site-wide vs. journal specific results, etc.

Current context
From @asmecher, in the context of #10324 (comment).

I think the only place this function is used is in the vocabs API controller, which is where the front end gets autosuggest possibilities. I think having a single endpoint for all vocab suggestions is actually the mistake -- it leads to the need for a single point of access for vocabs that might be attached to many different things, so we have to hard-code all the checks to make sure the list is allowed into a single place.

Instead, I suggest we break the endpoints where autosuggest responses are built into the appropriate places in the API. Autosuggestions for reviewer interests, which are global, should not be attached to the same endpoint as autosuggest results for article keywords, which are (probably) journal-specific.

@ewhanson, can we revisit the controlled vocab API handler? I don't think a single endpoint is the right design.

Code reference from ControlledVocab.php:

    /**
     * Scope a query to only include vocabs associated with given context id
     */
    public function scopeWithContextId(Builder $query, int $contextId): Builder
    {
        return $query
            ->where(
                fn ($query) => $query
                    ->select('context_id')
                    ->from('submissions')
                    ->whereColumn(
                        DB::raw(
                            "(SELECT publications.submission_id 
                            FROM publications 
                            INNER JOIN {$this->table} 
                            ON publications.publication_id = {$this->table}.assoc_id 
                            LIMIT 1)"
                        ),
                        '=',
                        'submissions.submission_id'
                    ), 
                $contextId
            );
    }

** TODO **

  • Establish which functionality needs its own endpoints
  • Create new endpoints for these pieces of functionality
  • [ ]
@ewhanson ewhanson added the Enhancement:1:Minor A new feature or improvement that can be implemented in less than 3 days. label Dec 18, 2024
@ewhanson ewhanson added this to the 3.6 milestone Dec 18, 2024
@ewhanson ewhanson self-assigned this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement:1:Minor A new feature or improvement that can be implemented in less than 3 days.
Projects
None yet
Development

No branches or pull requests

1 participant