Checking Delayed Status
tl; dr - What are good design patterns for responding when an action has not been completed for a certain duration?
Problem setting
I am making an application similar to farmerville. In this application, users have gardens that they care about. There are several variables that are tracked in each garden - humidity, temperature, ph, nitrate, etc. The application directs you to the care of the garden, creating tasks for you. It informs you if any of these variables is too low or too high based on the readings you sent. In addition, it reminds you to take a reading for a variable if you have not taken it for a certain period of time.
Garden data look like
// garden object
{
name: "Home garden",
variables: {
nitrate: {
currentValue: 1.7,
lastMeasuredAt: // some Date
},
nitrite: {
currentValue: 0.5,
lastMeasuredAt: // some Date
}
}
}
, , " ". - , 2,5 ppm. ,
{
name: "Add fertilizer",
instructions: "Open bag, dump on garden",
condition: {
variable: "nitrate",
operator: "$lt",
threshold: 2.5
}
}
condition , , - . MongoDB, , Javascript Meteor, .
query = { variables.nitrate.currentValue: { $lt : 2.5 }};
Gardens.find(query).observe({
added: function( garden ) {
},
removed: function( garden ) {
}
});
, , . , , ?
{
name: "Take a nitrate reading",
instructions: "Insert the nitrate probe",
condition: {
variable: "nitrate",
operator: "$lt",
interval: 2880
}
}
, , interval, threshold ...
expiration = moment().subtract(interval, 'minutes').toDate();
query = { variables.nitrate.lastMeasuredAt: { $gt: expiration }};
Gardens.find(query).observe({
added: function( garden ) {
},
removed: function( garden ) {
}
});
- , . . , ?
?
Meteor Tracker , peerlibrary:server-autorun . , - , Tracker.autorun.
- ?
, , , ?