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

Open
flowfalls opened this issue Feb 5, 2022 · 1 comment
Open

Allow catalogue to be re-indexed periodically #1399

flowfalls opened this issue Feb 5, 2022 · 1 comment
Milestone

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 michaelbromley moved this from v1.5 to In Progress in Vendure Roadmap Feb 24, 2022
@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 moved this from In Progress to v1.6 in Vendure Roadmap Mar 29, 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📅 Planned
Development

No branches or pull requests

2 participants