Skip to content
Snippets Groups Projects

analog year update

Merged Tucker Gary Siegel requested to merge gefs into master
5 files
+ 87
8
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -13,7 +13,7 @@ function send_response(message, gdds, data, res) {
@@ -13,7 +13,7 @@ function send_response(message, gdds, data, res) {
})
})
}
}
function find(collection, query, projection, t_base, res, product) {
function find(collection, query, projection, t_base, res, product, current) {
collection.findOne(query, projection).then(function(data) {
collection.findOne(query, projection).then(function(data) {
var min_temps = data["min_temps"]
var min_temps = data["min_temps"]
var max_temps = data["max_temps"]
var max_temps = data["max_temps"]
@@ -29,7 +29,17 @@ function find(collection, query, projection, t_base, res, product) {
@@ -29,7 +29,17 @@ function find(collection, query, projection, t_base, res, product) {
gdd_sum += gdd_value
gdd_sum += gdd_value
gdds.push(gdd_sum)
gdds.push(gdd_sum)
}
}
send_response("Accumulated GDDs", gdds, data, res);
if (current) {
 
analog_year = data["analog_year"]
 
} else {
 
analog_year = -1
 
}
 
res.json({message: "Accumulated GDDs",
 
date: data["last_date"],
 
data: gdds,
 
analog_year: analog_year,
 
closest_lon: data["location"]["coordinates"][0],
 
closest_lat: data["location"]["coordinates"][1]});
}, function(err) {
}, function(err) {
res.status(500).send({"internal error": err})
res.status(500).send({"internal error": err})
})
})
@@ -135,7 +145,8 @@ exports.accumulated_gdd = function (req, res) {
@@ -135,7 +145,8 @@ exports.accumulated_gdd = function (req, res) {
if (year != new Date().getFullYear()) {
if (year != new Date().getFullYear()) {
find(gdd_collection, query, projection, t_base, res, product);
find(gdd_collection, query, projection, t_base, res, product);
} else {
} else {
find(gdd_current_collection, query, projection, t_base, res, product);
projection["analog_year"] = 1;
 
find(gdd_current_collection, query, projection, t_base, res, product, true);
}
}
};
};
Loading