IBM / ibm-cloud-functions-serverless-iot-openfridge

WARNING: This repository is no longer maintained :warning: This repository will not be updated. The repository will be kept available in read-only mode. See https://developer.ibm.com/code/patterns/ for the latest patterns.
Apache License 2.0
20 stars 22 forks source link

Address logic error from Vincent Cailly #47

Closed krook closed 7 years ago

krook commented 7 years ago

Fix needed:

I just want to notify you that I have detected a bug. In the order database, the order status is systematically set to "pending", even if the warranty has not expired (status should be "ordered" if the warranty has not expired) So when the appliance sends a MQQT message indicating the need to replace a part, we never receive a mail "

To fix the issue, I made the following change in the code (line 61 of the openfridge/actions/create-order-event.js file)

Original code if (params.warranty_expiration > Math.floor(Date.now() / 1000)) {

Modified code if (appliance.warranty_expiration > Math.floor(Date.now() / 1000)) {