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

The given example is not meaningful, and the rule definition is incorrect (json payload in Github page). #88

Open
bharat-Kundapur opened this issue Dec 12, 2022 · 2 comments

Comments

@bharat-Kundapur
Copy link

bharat-Kundapur commented Dec 12, 2022

The rules definition on the GitHub page, which is a JSON payload, is invalid, and I'm not sure what's wrong, please post some valid examples of how to use this package. The example provided on the page is not functional.
Please provide some working examples.

@bharat-Kundapur bharat-Kundapur changed the title Given example is not a working one, rule Definition is invalid (json payload in Github page). The given example is not meaningful, and the rule definition is incorrect (json payload in Github page). Dec 12, 2022
@bharat-Kundapur
Copy link
Author

Could you please review the following rule definition, where I have made changes in the second set of rules where ANY and ALL conditions are together, there were previously two dictionaries inside the conditions dictionary without a key, so I made them sit within the same directory with keys ANY and ALL , instead of being separate dictionaries?

[

{"conditions": {"all": [
    {"name": "expiration_days",
     "operator": "less_than",
     "value": 5
     },
    {"name": "current_inventory",
     "operator": "greater_than",
     "value": 20
     }
]},
    "actions": [
        {"name": "put_on_sale",
         "params": {"sale_percentage": 0.25}
         }
    ]
},


{"conditions": {"any": [
    {"name": "current_inventory",
     "operator": "less_than",
     "value": 5
     }
],
    "all": [
        {"name": "current_month",
         "operator": "equal_to",
         "value": "December"
         },
        {"name": "current_inventory",
         "operator": "less_than",
         "value": 20
         }
    ]}
},
{"actions": [
    {"name": "order_more",
     "params": {"number_to_order": 40}
     }
]
}]

I cannot raise PR because I cannot run any examples given in the documents. can you guys help us with working examples?

@bharat-Kundapur
Copy link
Author

bharat-Kundapur commented Dec 13, 2022

Hi Guys, tested the bellow payload with Simple use case, but the package is not working as expected for ANY and ALL conditions together. anyway logically it's not appropriate, agree with that.

[

    {"conditions": {"all": [
        {"name": "expiration_days",
         "operator": "less_than",
         "value": 5
         },
        {"name": "current_inventory",
         "operator": "greater_than",
         "value": 20
         }
    ]},
        "actions": [
            {"name": "put_on_sale",
             "params": {"sale_percentage": 0.25}
             }
        ]
    },

    {
        "conditions": {"any": [
            {"name": "current_inventory",
             "operator": "less_than",
             "value": 5
             }
        ]},
        "actions": [
            {"name": "order_more",
             "params": {"number_to_order": 40}
             }
        ]
    }]

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

1 participant