medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
25.58k stars 2.55k forks source link

Batch Job filtering not working #5647

Open adamlamaa opened 11 months ago

adamlamaa commented 11 months ago

Bug report

Batch Job filtering not working.

It seems that querying based on any of the date fields is not support at the moment. Also the calculated "status" field is not available for filtering either. Which could provide some workarounds.

Describe the bug

Trying to filter all batch jobs that have failed in e.g. the past week.

Using the below react hook just returns all batch jobs and ignores the limit and offset properties.

import { useAdminBatchJobs } from 'medusa-react';

useAdminBatchJobs({
    failed_at: {
        gte: dateOneWeekAgo
    },
    limit: 30,
    offset: 0,
});

Pinging the api directly fails http://localhost:9000/admin/batch-jobs?limit=20&offset=0&failed_at=gte:2023-11-10T10:37:51.710Z image

http://localhost:9000/admin/batch-jobs?limit=20&offset=0&failed_at=2023-11-10 image

System information

Medusa version (including plugins):

    "@medusajs/admin": "7.1.7",
    "@medusajs/cache-inmemory": "1.8.10",
    "@medusajs/cache-redis": "1.9.0",
    "@medusajs/event-bus-local": "1.9.7",
    "@medusajs/event-bus-redis": "1.8.10",
    "@medusajs/icons": "1.1.0",
    "@medusajs/medusa": "1.17.4",
    "@medusajs/medusa-cli": "1.3.21",
    "@medusajs/medusa-js": "6.1.4",
    "@medusajs/types": "1.11.6",
    "@medusajs/ui": "2.2.1",
    "@medusajs/utils": "1.10.5",
    "@sendgrid/mail": "7.7.0",
    "@tanstack/react-query": "4.22.0",
    "graphql": "16.8.1",
    "medusa-file-s3": "1.4.0",
    "medusa-fulfillment-manual": "1.1.38",
    "medusa-interfaces": "1.3.7",
    "medusa-payment-manual": "1.0.24",
    "medusa-payment-stripe": "6.0.6",
    "medusa-plugin-meilisearch": "2.0.10",
    "medusa-react": "9.0.11",
    "node-fetch": "2.7.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "typeorm": "0.3.17",

Node.js version: 20.8 Database: Postgres Operating system: Mac Sonoma version 14.0

chemicalkosek commented 11 months ago

failed_at is an object so you would need to construct url like this:

http://localhost:9000/admin/batch-jobs?failed_at[gte]=2023-11-10T10:37:51.710Z
adamlamaa commented 11 months ago

@chemicalkosek thank you, I am able to query the backend manually with your corrected url.

The useAdminBatchJobs hook is however not working, so I will leave this issue open for now.