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

How to handle large number of tags? 1000 tags and growing #60

Closed
arcdelsol opened this issue Jun 20, 2019 · 7 comments
Closed

How to handle large number of tags? 1000 tags and growing #60

arcdelsol opened this issue Jun 20, 2019 · 7 comments

Comments

@arcdelsol
Copy link

My tag list is growing and noticed some delay on initial load. (Typeahead not loading any tags because it's still loading)
Obviously I can add a loading graphic, but that's not a long term solution as list of tags are expected to grow more.
Maybe handle infinite loading or pagination somehow?

@shiwangebuzhidao
Copy link

Same problem, I need to handle 10 thousands of tags in my project

@paulm17
Copy link

paulm17 commented Sep 13, 2019

I had the same issue.

Filling in the existing tags with > 1000 tags is not the correct answer. The best way is to do a search based on the input and do a like query to the db. This should yield an answer of no more than 25 results. The user can then enter more or less characters to get the desired result set or enter a new tag.

#20 has some code which should give you a partial answer. The op didn't include the code to fill in the search results array. So I will add that.

--- Main ---

fetch(search, callback) {
    let data = {
        query: search.search,
        limit: (search.limit > 25) ? search.limit : 25
    }

    axios.post('/api/dam/getTags', data)
    .then((response) => {
        let searchResults = [];

        for (let tag of response.data.data) {
            let item = {
                text: tag.tag
            };

            searchResults.push(item);
        }

        callback(searchResults)
    })
}

--- TagsInput.vue ---

if (this.typeaheadFetch && input.length > 0) {
    this.typeaheadFetch({ search: input, limit: this.typeaheadMaxResults }, (response) => {
            this.$nextTick(() => {
                this.searchResults = response;

                // We need to process the props update from the parent
                this.searchLoadedTag(input)
            });
        }
    );
} else {
    this.searchLoadedTag(input);
}

I have a working solution now.

@AlexMordred
Copy link
Member

I've finally implemented AJAX search, which will solve this problem. Now you don't need to feed the component a list of all the tags. It's up to you to limit the number of the results on the backend.

Will make a release soon.

@nickelnext
Copy link

Hi Alex.

I can specify the url, but my endpoint is protected by a token.
I'm using nuxt and usually my REST API calls are as such

this.$axios.$get

Is there a way to specify a function rather than just a url? So we can use our own logic to call the server/endpoint, and fetch the tags object array?

Thanks

@AlexMordred
Copy link
Member

Hey @nickelnext. Unfortunately, this is not possible at the moment. Do you feel like making a PR? :) If not, I might take a look at this.

P.S. Seems to be the same issue as #117.

@nickelnext
Copy link

Hi! I thought I replied already but i guess i didnt. Unfortunately i just started working with js and vue so i'm not that confident i'll be able to pull this off :(

@AlexMordred
Copy link
Member

@nickelnext ok, I'll tackle this. And let's move the discussion to #117.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants