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

Allow catalogue to be re-indexed periodically #1399

Closed
flowfalls opened this issue Feb 5, 2022 · 2 comments
Closed

Allow catalogue to be re-indexed periodically #1399

flowfalls opened this issue Feb 5, 2022 · 2 comments
Labels
P4: low Non-critical, workarounds exist status: blocked 🚧 Resolution is blocked by some other issue or external factor

Comments

@flowfalls
Copy link

Is your feature request related to a problem? Please describe.
Please add functionality to run the reindex() periodically. I need to have my customers know up-to-date information in regards to stock-levels.

Describe the solution you'd like
I'd like it to easily run the reindex() job; just as we do with the admin-ui button but removing the manual process.

Describe alternatives you've considered
I've had to use axios to login to the backend and make a graphql post in order to run the reindex via a cron job.

Additional context
current rudimentary solution:

@Cron(CronExpression.EVERY_10_SECONDS)
   async routineReindexing() {
       if (this.processContext.isWorker) {

           const jar = new CookieJar();
           const client = wrapper(axios.create({jar} as AxiosRequestConfig));

           await client({
               url: 'http://localhost:3000/admin-api',
               method: 'post',
               data: {
                   operationName: "AttemptLogin",
                   variables: {
                       "username": config.authOptions.superadminCredentials?.identifier,
                       "password": config.authOptions.superadminCredentials?.password,
                       "rememberMe": false
                   },
                   query: "mutation AttemptLogin($username: String!, $password: String!, $rememberMe: Boolean!) {\n  login(username: $username, password: $password, rememberMe: $rememberMe) {\n    ...CurrentUser\n    ...ErrorResult\n    __typename\n  }\n}\n\nfragment CurrentUser on CurrentUser {\n  id\n  identifier\n  channels {\n    id\n    code\n    token\n    permissions\n    __typename\n  }\n  __typename\n}\n\nfragment ErrorResult on ErrorResult {\n  errorCode\n  message\n  __typename\n}\n"

               }
           }).catch((reason => console.log(reason)));

           await client({
               url: 'http://localhost:3000/admin-api',
               method: 'post',
               withCredentials: true,
               data: {
                   query: `
                     mutation Reindex {
                         reindex {
                           id
                         }
                       }
                     `,
               },
           }).then((result) => {
               console.log(result.data)
           }).catch((reason => console.log(reason)));
       }
@michaelbromley
Copy link
Member

Relates to #1425 - the same mechanism discussed in that issue would be used to handle this use-case too.

@michaelbromley michaelbromley added this to the v1.7 milestone Jul 1, 2022
@michaelbromley michaelbromley moved this to 📅 Planned in Vendure OS Roadmap Jul 1, 2022
@michaelbromley michaelbromley modified the milestones: v1.7, v1.8 Jul 1, 2022
@michaelbromley michaelbromley modified the milestones: v1.8, v2.1 Sep 8, 2022
@dlhck dlhck moved this from 📅 Planned to 📦 Backlog in Vendure OS Roadmap Sep 24, 2024
@dlhck dlhck removed this from the v2.1 milestone Sep 24, 2024
@dlhck dlhck added the status: blocked 🚧 Resolution is blocked by some other issue or external factor label Sep 24, 2024
@martijnvdbrug martijnvdbrug added the P4: low Non-critical, workarounds exist label Dec 17, 2024
@martijnvdbrug
Copy link
Collaborator

Closing this to prevent duplicate issues: This specific feature probably won't be included in core, but you can track #1425 . When that is fixed, you can use that Scheduled Tasks mechanism to implement periodical catalog re-indexing for your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4: low Non-critical, workarounds exist status: blocked 🚧 Resolution is blocked by some other issue or external factor
Projects
None yet
Development

No branches or pull requests

4 participants