From cf09bf14131aa108c15b3f5f15dc748fecab2c21 Mon Sep 17 00:00:00 2001 From: Dave Landry Date: Fri, 23 Jun 2023 16:56:22 -0400 Subject: [PATCH] adds pumsLatestYear to naics and soc customAttributes --- api/customAttributes.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/customAttributes.js b/api/customAttributes.js index b64d6734..84d29b98 100644 --- a/api/customAttributes.js +++ b/api/customAttributes.js @@ -98,9 +98,15 @@ module.exports = function(app) { retObj.beaL0 = beaIds && beaIds.L0 ? beaIds.L0 : false; retObj.beaL1 = beaIds && beaIds.L1 ? beaIds.L1 : false; retObj.blsIds = blsInds[id] || false; + retObj.pumsLatestYear = await axios.get(`${origin}/api/data?${hierarchy}=${id}&measures=Total%20Population&limit=1&order=Year&sort=desc`) + .then(resp => resp.data.data[0]["ID Year"]) + .catch(() => 2020); } else if (dimension === "PUMS Occupation") { retObj.blsIds = blsOccs[id] || false; + retObj.pumsLatestYear = await axios.get(`${origin}/api/data?${hierarchy}=${id}&measures=Total%20Population&limit=1&order=Year&sort=desc`) + .then(resp => resp.data.data[0]["ID Year"]) + .catch(() => 2020); } else if (dimension === "CIP") { retObj.stem = id.length === 6 ? stems.includes(id) ? "Stem Major" : false : "Contains Stem Majors"