My Products
Help
CarlosV
PARTNER

Using Filter ChangeDateTime

by CarlosV

Hi,
A third-party developer creates a web portal integrated with VB NXT.
When they run the following query, with filter on processingMethod7 and changeDateTime:

 

query read_product
{
useCompany (no:4313304)
{product
(filter:
{_and :
[
{processingMethod7:{_eq: 1}},
{changedDateTime:{_gte:"2023-01-18T00:13:00"}}
]
}
sortOrder:{processingMethod7:ASC}
)
{
items
{
productNo
showOnWeb
changedDateTime
processingMethod7
productNo
}
}
}
}

they get in return data with processingMethod7=0 which should not be displayed.

 {
"productNo": "2990",
"showOnWeb": 0,
"changedDateTime": "2023-01-18T07:57:00",
"processingMethod7": 0,
"changedTime": 757
},
{
"productNo": "2991",
"showOnWeb": 0,
"changedDateTime": "2023-01-18T07:57:00",
"processingMethod7": 0,
"changedTime": 757
},
{
"productNo": "3000",
"showOnWeb": 1,
"changedDateTime": "2023-01-20T12:16:00",
"processingMethod7": 1,
"changedTime": 1216
},
{
"productNo": "3002",
"showOnWeb": 1,
"changedDateTime": "2023-01-20T12:16:00",
"processingMethod7": 1,
"changedTime": 1216
},

 

Does anyone know why return data that should not be displayed?

6 REPLIES 6

by Marius Bancila

If we will not hear back from you on this issue within a week, I will proceed to close our internal ticket on this issue.

CarlosV
PARTNER

by CarlosV

HI, you can close your ticket. This was solved with this filter, by using an ekstra _and

                                               filter: {

                                                               _and: [

                                                                               { _and: [{ processingMethod7: { _is_on: 1 } }]}

                                                                               { changedDateTime: { _gte: "2023-01-18T00:13:00" } }

                                                               ]

                                               }

by Marius Bancila

I am not able to reproduce your problem.

query read_product($cid: Int)
{
  useCompany (no:$cid)
  {
    product (filter: 
      {_and : 
       [
         {processingMethod1 :{_eq:32768}}
         {changedDateTime:{_gte:"2020-01-01T00:13:00"}}
       ]
      } 
      sortOrder:{processingMethod1:ASC})
    {
      totalCount
      items
      {
        productNo
        changedDateTime
        processingMethod1
      }
    }
  }
}

Result:

{
  "data": {
    "useCompany": {
      "product": {
        "totalCount": 2,
        "items": [
          {
            "productNo": "9000",
            "changedDateTime": "2020-05-11T13:25:00",
            "processingMethod1": 32768
          },
          {
            "productNo": "9001",
            "changedDateTime": "2020-05-11T13:25:00",
            "processingMethod1": 32768
          }
        ]
      }
    }
  }
}

On the other hand:

query read_product($cid: Int)
{
  useCompany (no:$cid)
  {
    product (filter: {changedDateTime:{_gte:"2020-01-01T00:13:00"}},
      sortOrder:{processingMethod1:ASC})
    {
      totalCount
      items
      {
        productNo
        changedDateTime
        processingMethod1
      }
    }
  }
}

Produces:

{
  "data": {
    "useCompany": {
      "product": {
        "totalCount": 74,
        "items": [
          {
            "productNo": "1001",
            "changedDateTime": "2020-05-11T13:25:00",
            "processingMethod1": 0
          },
          {
            "productNo": "1002",
            "changedDateTime": "2020-05-11T13:25:00",
            "processingMethod1": 0
          },
          {
            "productNo": "101",
            "changedDateTime": "2020-05-11T13:25:00",
            "processingMethod1": 0
          },
...

I have tried various queries with the same result.

 

by Marius Bancila

Thank you for reporting this. I will investigate the problem. In the meanwhile, please use Ole's workaround.

omelhus
PARTNER

by omelhus (Updated ‎24-01-2023 09:20 by omelhus PARTNER )

I think there's a bug with DateTimes and _gte. Try something like this instead, with the added benefit of checking on ms instead of minutes.

 

 filter: {
        _and: [
          {
            _or: [
              { changedDate: { _gt: $lastModifiedDate } }
              {
                _and: [
                  { changedDate: { _eq: $lastModifiedDate } }
                  { changeTimeInMs: { _gte: $lastModifiedDateMs } }
                ]
              }
            ]
          }
          { processingMethod7: { _gt: 0 } }
        ]
      }

 

Remember that processingMethod7 is a flag-field, so you should check for bit values instead of just equals. To check if flag 1 is on do processingMethod7  & 1 = 1 in your code.

CarlosV
PARTNER

by CarlosV

Thank .