From 57bca798abe7d52bfbaad6596557d05babc31f7a Mon Sep 17 00:00:00 2001 From: Joyce J Nimely Date: Mon, 22 Jun 2026 10:20:44 -0400 Subject: [PATCH 1/8] changed the service name to match the african american service. --- .../data/african-american-history.js | 53 +++++++++++++++ .../data/blackWomenInSTEM | 25 +++++++ .../data/blackWomenInSTEM.js | 66 +++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 src/procedures/african-american-history/data/african-american-history.js create mode 100644 src/procedures/african-american-history/data/blackWomenInSTEM create mode 100644 src/procedures/african-american-history/data/blackWomenInSTEM.js diff --git a/src/procedures/african-american-history/data/african-american-history.js b/src/procedures/african-american-history/data/african-american-history.js new file mode 100644 index 00000000..e5aca2d7 --- /dev/null +++ b/src/procedures/african-american-history/data/african-american-history.js @@ -0,0 +1,53 @@ +/** + * Access to datasets celebrating African American history and contributions, + * organized by topic (Women in STEM, with more topics to come). + * + * See https://www.esrl.noaa.gov/gmd/ccgg/trends/ for additional details. + * + * @service + * @category History //this is the category for the service + */ + +const { getData } = require("./data"); + +const AfricanAmericanHistory = {}; //this add everthing inside this container +AfricanAmericanHistory.servicename = "AfricanAmericanHistory"; + +/** + * Get the mole fraction of CO2 (in parts per million) by year. Missing measurements + * are interpolated. + * + * If ``startyear`` or ``endyear`` is provided, only measurements within the given range will be returned. + * + * @param {Number=} startyear first year of data to include + * @param {String=} endyear last year of data to include + * @returns {String} + */ +AfricanAmericanHistory.helloFromSaman = async function ( + startyear = -Infinity, + endyear = Infinity, +) { + return "hello saman" +}; + +/** + * Get the mole fraction of CO2 (in parts per million) by year with the seasonal + * cycle removed. + * + * If ``startyear`` or ``endyear`` is provided, only measurements within the given range will be returned. + * + * @param {Number=} startyear first year of data to include + * @param {Number=} endyear last year of data to include + * @returns {Array} + */ +MaunaLoaCO2Data.getCO2Trend = async function ( + startyear = -Infinity, + endyear = Infinity, +) { + return (await getData()).filter((datum) => + datum.date > startyear && datum.date < endyear + ) + .map((datum) => [datum.date, datum.trend]); +}; + +module.exports = MaunaLoaCO2Data; diff --git a/src/procedures/african-american-history/data/blackWomenInSTEM b/src/procedures/african-american-history/data/blackWomenInSTEM new file mode 100644 index 00000000..081292d9 --- /dev/null +++ b/src/procedures/african-american-history/data/blackWomenInSTEM @@ -0,0 +1,25 @@ +name,field,dates,notes +,Kandis Leslie Abdul-Aziz,chemical engineer and environmental engineer, +,Rediet Abebe,computer scientist,1991– +,Lilia Ann Abron,chemical engineering and environmental engineering,1945– +,Stephanie G. Adams,engineer and academic administrator, +,Lucile Adams-Campbell,epidemiology,1953– +,Javaune Adams-Gaston,psychologist and academic administrator, +,Paris Adkins-Jackson,epidemiology, +,Modupe Akinola,organizational scholar and social psychologist,1974– +,Jacqueline Akinpelu,"applied mathematician, operations researcher",1953– +,Delores P. Aldridge,sociologist,1941– +,Claudia Alexander,"geophysics, planetary science",1959–2015 +,Beverly Anderson,mathematician,1943– +,Cheryl Anderson,epidemiologist, +,Giovonnae Anderson,electrical engineering, +,Gloria Long Anderson,chemistry,1938– +,Ayana Holloway Arce,physicist and professor, +,Treena Livingston Arinzeh,biomedical engineering,1970– +,Ludmilla Aristilde,engineer, +,Elayne Arrington,mathematician and engineer,1940– +,Valerie Ashby,chemist, +,Estella Atekwana,Biogeophysics; tectonphysics,1961– +,Balanda Atis,cosmetic science, +,Donna Auguste,"businesswoman, computer scientist",1958– +,Wanda Austin,aerospace engineering,1954– diff --git a/src/procedures/african-american-history/data/blackWomenInSTEM.js b/src/procedures/african-american-history/data/blackWomenInSTEM.js new file mode 100644 index 00000000..e56e8fa1 --- /dev/null +++ b/src/procedures/african-american-history/data/blackWomenInSTEM.js @@ -0,0 +1,66 @@ +const fs = require("fs").promises; +const path = require("path"); +const axios = require("axios"); + +const logger = require("../../utils/logger")("mauna-loa-co2-data"); + +const DATA_SOURCE = + "https://gml.noaa.gov/webdata/ccgg/trends/co2/co2_mm_mlo.txt"; +const DATA_SOURCE_LIFETIME = 1 * 24 * 60 * 60 * 1000; // 1 day + +function restructure(content) { + return content.split("\n") + .map((s) => s.trim()) + .filter((s) => s && !s.startsWith("#")) + .map((line) => { + const [, , date, interpolated, trend] = line.split(/\s+/).map(parseFloat); + if ( + date < 1800 || date > 2200 || interpolated < 250 || + interpolated > 1500 | trend < 250 || trend > 1500 + ) { + throw Error( + "CO2 data columns are not as expected - they might have changed the file organization", + ); + } + return { date, interpolated, trend }; + }); +} +async function loadDataFile() { + const filename = path.join(__dirname, "co2_mm_mlo.txt"); + return restructure(await fs.readFile(filename, "utf8")); +} + +let CACHED_DATA = undefined; +let CACHE_TIME_STAMP = undefined; +async function getData() { + if ( + CACHED_DATA !== undefined && + Date.now() - CACHE_TIME_STAMP <= DATA_SOURCE_LIFETIME + ) return CACHED_DATA; + + let res = await loadDataFile(); // default to the data file we have, in case the up-to-date download/restructure fails + + logger.info(`requesting data from ${DATA_SOURCE}`); + const resp = await axios({ url: DATA_SOURCE, method: "GET" }); + if (resp.status !== 200) { + logger.error("download failed with status", resp.status); + logger.error("falling back to saved file"); + } else { + logger.info("download complete - restructuring data"); + try { + res = restructure(resp.data); + } catch (err) { + logger.error("restructure failed:", err); + logger.error("falling back to saved file"); + } + } + + logger.info("caching result"); + CACHED_DATA = res; + CACHE_TIME_STAMP = Date.now(); + return res; +} + +module.exports = { + getData, +}; From 38b7ba346fd6293adff07f4dbce7634043573623 Mon Sep 17 00:00:00 2001 From: Joyce J Nimely Date: Tue, 23 Jun 2026 13:13:29 -0500 Subject: [PATCH 2/8] Added a function to get women in STEM, with optional filter by field --- .../african-american-data.js | 48 +++++++++++++++++ .../data/black_women_stem.csv file.csv | 25 +++++++++ .../data/index.js} | 0 .../data/african-american-history.js | 53 ------------------- .../data/blackWomenInSTEM | 25 --------- 5 files changed, 73 insertions(+), 78 deletions(-) create mode 100644 src/procedures/african-american-data/african-american-data.js create mode 100644 src/procedures/african-american-data/data/black_women_stem.csv file.csv rename src/procedures/{african-american-history/data/blackWomenInSTEM.js => african-american-data/data/index.js} (100%) delete mode 100644 src/procedures/african-american-history/data/african-american-history.js delete mode 100644 src/procedures/african-american-history/data/blackWomenInSTEM diff --git a/src/procedures/african-american-data/african-american-data.js b/src/procedures/african-american-data/african-american-data.js new file mode 100644 index 00000000..189d06b4 --- /dev/null +++ b/src/procedures/african-american-data/african-american-data.js @@ -0,0 +1,48 @@ +/** + * Access to NOAA Earth System Research Laboratory data collected from Mauna Loa, Hawaii. + * + * See https://www.esrl.noaa.gov/gmd/ccgg/trends/ for additional details. + * + * @service + * @category History + */ + +const { getData } = require("./data"); +const AfricanAmericanHistory = {}; +AfricanAmericanHistory.serviceName = "AfricanAmericanData"; + +/** + * Get all women in STEM, optionally filtered by field of study. + * + * @param {String=} field optional field to filter by (e.g. "chemistry", "engineering") + * @returns {Array} + */ +AfricanAmericanHistory.getWomenInSTEM = async function (field) { + const people = await getData(); + if (!field) return people; + return people.filter((p) => + p.field.toLowerCase().includes(field.toLowerCase()) + ); +}; + +/** + * Get the mole fraction of CO2 (in parts per million) by year with the seasonal + * cycle removed. + * + * If ``startyear`` or ``endyear`` is provided, only measurements within the given range will be returned. + * + * @param {Number=} startyear first year of data to include + * @param {Number=} endyear last year of data to include + * @returns {Array} + */ +AfricanAmericanHistory.getCO2Trend = async function ( + startyear = -Infinity, + endyear = Infinity, +) { + return (await getData()).filter((datum) => + datum.date > startyear && datum.date < endyear + ) + .map((datum) => [datum.date, datum.trend]); +}; + +module.exports = AfricanAmericanHistory; diff --git a/src/procedures/african-american-data/data/black_women_stem.csv file.csv b/src/procedures/african-american-data/data/black_women_stem.csv file.csv new file mode 100644 index 00000000..8650430a --- /dev/null +++ b/src/procedures/african-american-data/data/black_women_stem.csv file.csv @@ -0,0 +1,25 @@ +name,field,dates,notes +Kandis Leslie Abdul-Aziz,chemical engineer and environmental engineer,,Developer of technologies that turn agricultural waste into a filtration system for water +Rediet Abebe,computer scientist,1991–,First female computer scientist to be appointed to the Harvard Society of Fellows +Lilia Ann Abron,chemical engineering and environmental engineering,1945–,First African-American woman to earn a PhD in chemical engineering +Stephanie G. Adams,engineer and academic administrator,,Dean of the Erik Jonsson School of Engineering and Computer Science at the University of Texas at Dallas since 2019 +Lucile Adams-Campbell,epidemiology,1953–,First African-American woman to receive a PhD in epidemiology in the United States. Serves as the Professor of Oncology at Lombardi Comprehensive Cancer Center and associate director for Minority Health at the Georgetown University Medical Center. +Javaune Adams-Gaston,psychologist and academic administrator,,President of Norfolk State University since 2019. +Paris Adkins-Jackson,epidemiology,,Assistant Professor of Epidemiology and Sociomedical Sciences in the Mailman School of Public Health at Columbia University in New York. +Modupe Akinola,organizational scholar and social psychologist,1974–,"Researches the science of stress, creativity, and how to maximize human potential in diverse organizations." +Jacqueline Akinpelu,"applied mathematician, operations researcher",1953–,"Research manager at the Applied Physics Laboratory of Johns Hopkins University, and developed a pipeline for students from Morgan State University to mentor them into careers in STEM fields." +Delores P. Aldridge,sociologist,1941–,First African-American woman faculty member of Emory University and founding director of the first African-American and African-Studies degree-granting program in the South. +Claudia Alexander,"geophysics, planetary science",1959–2015,Project manager for NASA's Galileo mission and Rosetta mission +Beverly Anderson,mathematician,1943–,"Emeritus professor at the University of the District of Columbia, and in the 1990s, worked at the National Academy of Sciences as Director of Minority Programs for the Mathematical Sciences Education Board" +Cheryl Anderson,epidemiologist,,Professor at and founding Dean of the University of California San Diego Herbert Wertheim School of Public Health and Human Longevity Science +Giovonnae Anderson,electrical engineering,,"First African-American women to earn a PhD in electrical engineering at the University of California, Davis (1979): Giovonnae Anderson" +Gloria Long Anderson,chemistry,1938–,"Pioneer of nuclear magnetic resonance spectroscopy, known for work with fluorine-19 and solid rocket propellants" +Ayana Holloway Arce,physicist and professor,,"Associate professor of Duke University who works on particle physics, using data from the Large Hadron Collider to understand phenomena beyond the Standard Model" +Treena Livingston Arinzeh,biomedical engineering,1970–,Researcher of adult stem-cell therapy +Ludmilla Aristilde,engineer,,Professor at Northwestern University whose research considers environmental biochemistry and bioengineering +Elayne Arrington,mathematician and engineer,1940–,First African-American woman to graduate with a bachelor's degree from the School of Engineering at the University of Pittsburgh +Valerie Ashby,chemist,,"Chemist and university professor currently serving as president of the University of Maryland, Baltimore County" +Estella Atekwana,Biogeophysics; tectonphysics,1961–,"In August 2021 began tenure as dean of the largest college of the University of California, Davis: UC Davis College of Letters and Science" +Balanda Atis,cosmetic science,,Cosmetic chemist at L'Oréal USA who expanded range of cosmetics available for people of color +Donna Auguste,"businesswoman, computer scientist",1958–,Senior engineering manager for the Newton personal digital assistant (PDA) +Wanda Austin,aerospace engineering,1954–,Former president and CEO of The Aerospace Corporation diff --git a/src/procedures/african-american-history/data/blackWomenInSTEM.js b/src/procedures/african-american-data/data/index.js similarity index 100% rename from src/procedures/african-american-history/data/blackWomenInSTEM.js rename to src/procedures/african-american-data/data/index.js diff --git a/src/procedures/african-american-history/data/african-american-history.js b/src/procedures/african-american-history/data/african-american-history.js deleted file mode 100644 index e5aca2d7..00000000 --- a/src/procedures/african-american-history/data/african-american-history.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Access to datasets celebrating African American history and contributions, - * organized by topic (Women in STEM, with more topics to come). - * - * See https://www.esrl.noaa.gov/gmd/ccgg/trends/ for additional details. - * - * @service - * @category History //this is the category for the service - */ - -const { getData } = require("./data"); - -const AfricanAmericanHistory = {}; //this add everthing inside this container -AfricanAmericanHistory.servicename = "AfricanAmericanHistory"; - -/** - * Get the mole fraction of CO2 (in parts per million) by year. Missing measurements - * are interpolated. - * - * If ``startyear`` or ``endyear`` is provided, only measurements within the given range will be returned. - * - * @param {Number=} startyear first year of data to include - * @param {String=} endyear last year of data to include - * @returns {String} - */ -AfricanAmericanHistory.helloFromSaman = async function ( - startyear = -Infinity, - endyear = Infinity, -) { - return "hello saman" -}; - -/** - * Get the mole fraction of CO2 (in parts per million) by year with the seasonal - * cycle removed. - * - * If ``startyear`` or ``endyear`` is provided, only measurements within the given range will be returned. - * - * @param {Number=} startyear first year of data to include - * @param {Number=} endyear last year of data to include - * @returns {Array} - */ -MaunaLoaCO2Data.getCO2Trend = async function ( - startyear = -Infinity, - endyear = Infinity, -) { - return (await getData()).filter((datum) => - datum.date > startyear && datum.date < endyear - ) - .map((datum) => [datum.date, datum.trend]); -}; - -module.exports = MaunaLoaCO2Data; diff --git a/src/procedures/african-american-history/data/blackWomenInSTEM b/src/procedures/african-american-history/data/blackWomenInSTEM deleted file mode 100644 index 081292d9..00000000 --- a/src/procedures/african-american-history/data/blackWomenInSTEM +++ /dev/null @@ -1,25 +0,0 @@ -name,field,dates,notes -,Kandis Leslie Abdul-Aziz,chemical engineer and environmental engineer, -,Rediet Abebe,computer scientist,1991– -,Lilia Ann Abron,chemical engineering and environmental engineering,1945– -,Stephanie G. Adams,engineer and academic administrator, -,Lucile Adams-Campbell,epidemiology,1953– -,Javaune Adams-Gaston,psychologist and academic administrator, -,Paris Adkins-Jackson,epidemiology, -,Modupe Akinola,organizational scholar and social psychologist,1974– -,Jacqueline Akinpelu,"applied mathematician, operations researcher",1953– -,Delores P. Aldridge,sociologist,1941– -,Claudia Alexander,"geophysics, planetary science",1959–2015 -,Beverly Anderson,mathematician,1943– -,Cheryl Anderson,epidemiologist, -,Giovonnae Anderson,electrical engineering, -,Gloria Long Anderson,chemistry,1938– -,Ayana Holloway Arce,physicist and professor, -,Treena Livingston Arinzeh,biomedical engineering,1970– -,Ludmilla Aristilde,engineer, -,Elayne Arrington,mathematician and engineer,1940– -,Valerie Ashby,chemist, -,Estella Atekwana,Biogeophysics; tectonphysics,1961– -,Balanda Atis,cosmetic science, -,Donna Auguste,"businesswoman, computer scientist",1958– -,Wanda Austin,aerospace engineering,1954– From afc685ad3bd660d6d679e085cdcd3cad6102c561 Mon Sep 17 00:00:00 2001 From: Joyce J Nimely Date: Tue, 23 Jun 2026 13:21:28 -0500 Subject: [PATCH 3/8] Add getRandomWomanInSTEM function and export the service --- .../african-american-data.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/procedures/african-american-data/african-american-data.js b/src/procedures/african-american-data/african-american-data.js index 189d06b4..427fdb67 100644 --- a/src/procedures/african-american-data/african-american-data.js +++ b/src/procedures/african-american-data/african-american-data.js @@ -31,18 +31,12 @@ AfricanAmericanHistory.getWomenInSTEM = async function (field) { * * If ``startyear`` or ``endyear`` is provided, only measurements within the given range will be returned. * - * @param {Number=} startyear first year of data to include - * @param {Number=} endyear last year of data to include - * @returns {Array} + * @param {string=} field first year of data to include + * @returns {object} */ -AfricanAmericanHistory.getCO2Trend = async function ( - startyear = -Infinity, - endyear = Infinity, -) { - return (await getData()).filter((datum) => - datum.date > startyear && datum.date < endyear - ) - .map((datum) => [datum.date, datum.trend]); +AfricanAmericanHistory.getRandomWomanInSTEM = async function (field) { + const people = await this.getWomenInSTEM(field); + return people[Math.floor(Math.random() * people.length)]; }; module.exports = AfricanAmericanHistory; From 02f222bcbd2ff87463be07a2253a073566ed0c8f Mon Sep 17 00:00:00 2001 From: Joyce J Nimely Date: Mon, 29 Jun 2026 11:35:21 -0500 Subject: [PATCH 4/8] updated the csv file --- .../african-american-data.js | 10 +- ...stem.csv file.csv => black_women_stem.csv} | 0 .../african-american-data/data/index.js | 129 +++++++++++------- 3 files changed, 86 insertions(+), 53 deletions(-) rename src/procedures/african-american-data/data/{black_women_stem.csv file.csv => black_women_stem.csv} (100%) diff --git a/src/procedures/african-american-data/african-american-data.js b/src/procedures/african-american-data/african-american-data.js index 427fdb67..9f35d075 100644 --- a/src/procedures/african-american-data/african-american-data.js +++ b/src/procedures/african-american-data/african-american-data.js @@ -26,17 +26,15 @@ AfricanAmericanHistory.getWomenInSTEM = async function (field) { }; /** - * Get the mole fraction of CO2 (in parts per million) by year with the seasonal - * cycle removed. + * Get one random woman in STEM, optionally filtered by field of study. * - * If ``startyear`` or ``endyear`` is provided, only measurements within the given range will be returned. - * - * @param {string=} field first year of data to include - * @returns {object} + * @param {String=} field optional field to filter by + * @returns {Object} */ AfricanAmericanHistory.getRandomWomanInSTEM = async function (field) { const people = await this.getWomenInSTEM(field); return people[Math.floor(Math.random() * people.length)]; }; + module.exports = AfricanAmericanHistory; diff --git a/src/procedures/african-american-data/data/black_women_stem.csv file.csv b/src/procedures/african-american-data/data/black_women_stem.csv similarity index 100% rename from src/procedures/african-american-data/data/black_women_stem.csv file.csv rename to src/procedures/african-american-data/data/black_women_stem.csv diff --git a/src/procedures/african-american-data/data/index.js b/src/procedures/african-american-data/data/index.js index e56e8fa1..c9fd79d7 100644 --- a/src/procedures/african-american-data/data/index.js +++ b/src/procedures/african-american-data/data/index.js @@ -1,66 +1,101 @@ -const fs = require("fs").promises; -const path = require("path"); -const axios = require("axios"); +// const fs = require("fs").promises; +// const path = require("path"); +// const axios = require("axios"); + +// const logger = require("../../utils/logger")("mauna-loa-co2-data"); + +// const DATA_SOURCE = +// "https://gml.noaa.gov/webdata/ccgg/trends/co2/co2_mm_mlo.txt"; +// const DATA_SOURCE_LIFETIME = 1 * 24 * 60 * 60 * 1000; // 1 day + +// function restructure(content) { +// return content.split("\n") +// .map((s) => s.trim()) +// .filter((s) => s && !s.startsWith("#")) +// .map((line) => { +// const [, , date, interpolated, trend] = line.split(/\s+/).map(parseFloat); +// if ( +// date < 1800 || date > 2200 || interpolated < 250 || +// interpolated > 1500 | trend < 250 || trend > 1500 +// ) { +// throw Error( +// "CO2 data columns are not as expected - they might have changed the file organization", +// ); +// } +// return { date, interpolated, trend }; +// }); +// } +// async function loadDataFile() { +// const filename = path.join(__dirname, "co2_mm_mlo.txt"); +// return restructure(await fs.readFile(filename, "utf8")); +// } + +// let CACHED_DATA = undefined; +// let CACHE_TIME_STAMP = undefined; +// async function getData() { +// if ( +// CACHED_DATA !== undefined && +// Date.now() - CACHE_TIME_STAMP <= DATA_SOURCE_LIFETIME +// ) return CACHED_DATA; + +// let res = await loadDataFile(); // default to the data file we have, in case the up-to-date download/restructure fails + +// logger.info(`requesting data from ${DATA_SOURCE}`); +// const resp = await axios({ url: DATA_SOURCE, method: "GET" }); +// if (resp.status !== 200) { +// logger.error("download failed with status", resp.status); +// logger.error("falling back to saved file"); +// } else { +// logger.info("download complete - restructuring data"); +// try { +// res = restructure(resp.data); +// } catch (err) { +// logger.error("restructure failed:", err); +// logger.error("falling back to saved file"); +// } +// } -const logger = require("../../utils/logger")("mauna-loa-co2-data"); +// logger.info("caching result"); +// CACHED_DATA = res; +// CACHE_TIME_STAMP = Date.now(); +// return res; +// } -const DATA_SOURCE = - "https://gml.noaa.gov/webdata/ccgg/trends/co2/co2_mm_mlo.txt"; -const DATA_SOURCE_LIFETIME = 1 * 24 * 60 * 60 * 1000; // 1 day +// module.exports = { +// getData, +// }; + +const fs = require("fs").promises; +const path = require("path"); function restructure(content) { return content.split("\n") .map((s) => s.trim()) - .filter((s) => s && !s.startsWith("#")) + .filter((s) => s) + .slice(1) // skip header row: name,field,dates,notes .map((line) => { - const [, , date, interpolated, trend] = line.split(/\s+/).map(parseFloat); - if ( - date < 1800 || date > 2200 || interpolated < 250 || - interpolated > 1500 | trend < 250 || trend > 1500 - ) { - throw Error( - "CO2 data columns are not as expected - they might have changed the file organization", - ); - } - return { date, interpolated, trend }; + // Need to handle commas INSIDE quoted fields (like "geophysics, planetary science") + const matches = line.match(/(".*?"|[^",]+)(?=\s*,|\s*$)/g); + const [name, field, dates, notes] = matches.map((s) => + s.replace(/^"|"$/g, "").trim() + ); + return { name, field, dates, notes }; }); } + async function loadDataFile() { - const filename = path.join(__dirname, "co2_mm_mlo.txt"); + const filename = path.join(__dirname, "black_women_stem.csv"); return restructure(await fs.readFile(filename, "utf8")); } let CACHED_DATA = undefined; -let CACHE_TIME_STAMP = undefined; -async function getData() { - if ( - CACHED_DATA !== undefined && - Date.now() - CACHE_TIME_STAMP <= DATA_SOURCE_LIFETIME - ) return CACHED_DATA; - - let res = await loadDataFile(); // default to the data file we have, in case the up-to-date download/restructure fails - logger.info(`requesting data from ${DATA_SOURCE}`); - const resp = await axios({ url: DATA_SOURCE, method: "GET" }); - if (resp.status !== 200) { - logger.error("download failed with status", resp.status); - logger.error("falling back to saved file"); - } else { - logger.info("download complete - restructuring data"); - try { - res = restructure(resp.data); - } catch (err) { - logger.error("restructure failed:", err); - logger.error("falling back to saved file"); - } - } - - logger.info("caching result"); - CACHED_DATA = res; - CACHE_TIME_STAMP = Date.now(); - return res; +async function getData() { + if (CACHED_DATA !== undefined) return CACHED_DATA; + CACHED_DATA = await loadDataFile(); + return CACHED_DATA; } module.exports = { getData, -}; +}; \ No newline at end of file From c7d9d78e4ac4a21946cfa9b42dabb0138b4b15be Mon Sep 17 00:00:00 2001 From: Joyce J Nimely Date: Mon, 27 Jul 2026 14:01:52 -0500 Subject: [PATCH 5/8] added the base URL of the API --- .../african-american-data.js | 55 +++++++------------ 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/src/procedures/african-american-data/african-american-data.js b/src/procedures/african-american-data/african-american-data.js index 9f35d075..61a38e4d 100644 --- a/src/procedures/african-american-data/african-american-data.js +++ b/src/procedures/african-american-data/african-american-data.js @@ -1,40 +1,27 @@ /** - * Access to NOAA Earth System Research Laboratory data collected from Mauna Loa, Hawaii. + * African American Data * - * See https://www.esrl.noaa.gov/gmd/ccgg/trends/ for additional details. + * Explore African American people, history, media, culture, + * and community resources. * * @service * @category History */ - -const { getData } = require("./data"); -const AfricanAmericanHistory = {}; -AfricanAmericanHistory.serviceName = "AfricanAmericanData"; - -/** - * Get all women in STEM, optionally filtered by field of study. - * - * @param {String=} field optional field to filter by (e.g. "chemistry", "engineering") - * @returns {Array} - */ -AfricanAmericanHistory.getWomenInSTEM = async function (field) { - const people = await getData(); - if (!field) return people; - return people.filter((p) => - p.field.toLowerCase().includes(field.toLowerCase()) - ); -}; - -/** - * Get one random woman in STEM, optionally filtered by field of study. - * - * @param {String=} field optional field to filter by - * @returns {Object} - */ -AfricanAmericanHistory.getRandomWomanInSTEM = async function (field) { - const people = await this.getWomenInSTEM(field); - return people[Math.floor(Math.random() * people.length)]; -}; - - -module.exports = AfricanAmericanHistory; + +const ApiConsumer = require("../utils/api-consumer"); + +const BASE_URL = + "http://flask-api-env.eba-er3e5y3h.us-east-2.elasticbeanstalk.com/api"; + +const AfricanAmericanData = new ApiConsumer( + "AfricanAmericanData", + BASE_URL, + { + cache: { ttl: 5 * 60 }, + } +); + +function encode(value) { + return encodeURIComponent(String(value || "").trim()); +} + From 5252cca4923d559a54c482e1f2ef59327fbc9f82 Mon Sep 17 00:00:00 2001 From: Joyce J Nimely Date: Mon, 27 Jul 2026 14:03:31 -0500 Subject: [PATCH 6/8] Add getAllPeople, searchPeople, and getRandomPerson blocks --- .../african-american-data.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/procedures/african-american-data/african-american-data.js b/src/procedures/african-american-data/african-american-data.js index 61a38e4d..a5f29674 100644 --- a/src/procedures/african-american-data/african-american-data.js +++ b/src/procedures/african-american-data/african-american-data.js @@ -24,4 +24,46 @@ const AfricanAmericanData = new ApiConsumer( function encode(value) { return encodeURIComponent(String(value || "").trim()); } + // PEOPLE +// Fields: +// name, achievement, occupation, category, image +/** + * Get the names of all people. + * + * @category People + * @returns {Array} all person names + */ +AfricanAmericanData.getAllPeople = async function () { + const people = await this._requestData({ + path: "/people", + }); + return people.map((person) => person.name); +}; + +/** + * Search people by name, occupation, achievement, or category. + * + * @category People + * @param {String} nameOrFieldOrCategory search term + * @returns {Array} matching person names + */ +AfricanAmericanData.searchPeople = async function (nameOrFieldOrCategory) { + const people = await this._requestData({ + path: `/people/search?q=${encode(nameOrFieldOrCategory)}`, + }); + return people.map((person) => person.name); +}; + +/** + * Get the name of one random person. + * + * @category People + * @returns {String} the random person's name + */ +AfricanAmericanData.getRandomPerson = async function () { + const person = await this._requestData({ + path: "/people/random", + }); + return person.name || ""; +}; From 1ef40c0488aa673a21c2c7e40ffed0c502954cb6 Mon Sep 17 00:00:00 2001 From: Joyce J Nimely Date: Mon, 27 Jul 2026 14:42:54 -0500 Subject: [PATCH 7/8] Added full AfricanAmericanData service (People, History, Media, Culture, Community) --- .../african-american-data.js | 600 ++++++++++++++++++ 1 file changed, 600 insertions(+) diff --git a/src/procedures/african-american-data/african-american-data.js b/src/procedures/african-american-data/african-american-data.js index a5f29674..2051a91a 100644 --- a/src/procedures/african-american-data/african-american-data.js +++ b/src/procedures/african-american-data/african-american-data.js @@ -67,3 +67,603 @@ AfricanAmericanData.getRandomPerson = async function () { }); return person.name || ""; }; + +/** + * Get people from a category. + * + * @category People + * @param {String} category category name + * @returns {Array} matching person records + */ +AfricanAmericanData.getPeopleByCategory = async function (category) { + return this._requestData({ + path: `/people/category/${encode(category)}`, + }); +}; + +/** + * Get all available people categories. + * + * @category People + * @returns {Array} category names + */ +AfricanAmericanData.getPeopleCategories = async function () { + return this._requestData({ + path: "/people/categories", + }); +}; + +async function lookupPerson(self, name) { + return self._requestData({ + path: `/people/lookup/${encode(name)}`, + }); +} + +/** + * Get a person's achievement or trivia clue. + * + * @category People + * @param {String} name the person's name + * @returns {String} the person's achievement + */ +AfricanAmericanData.getPersonAchievement = async function (name) { + const person = await lookupPerson(this, name); + return person.achievement || ""; +}; + +/** + * Get a person's occupation. + * + * @category People + * @param {String} name the person's name + * @returns {String} the person's occupation + */ +AfricanAmericanData.getPersonOccupation = async function (name) { + const person = await lookupPerson(this, name); + return person.occupation || ""; +}; + +/** + * Get a person's category. + * + * @category People + * @param {String} name the person's name + * @returns {String} the person's category + */ +AfricanAmericanData.getPersonCategory = async function (name) { + const person = await lookupPerson(this, name); + return person.category || ""; +}; + +/** + * Get a person's image. + * + * @category People + * @param {String} name the person's name + * @returns {Image} the person's image + */ +AfricanAmericanData.getPersonImage = async function (name) { + const person = await lookupPerson(this, name); + return this._sendImage({ + baseUrl: person.image, + }); +}; + +// HISTORY +// title, summary, year, location, category, image + +/** + * Get the titles of all historical events. + * + * @category History + * @returns {Array} all event titles + */ +AfricanAmericanData.getAllHistoryEvents = async function () { + const events = await this._requestData({ + path: "/history", + }); + return events.map((event) => event.title); +}; + +/** + * Search historical events by title, summary, location, + * year, or category. + * + * @category History + * @param {String} titleOrCategory search term + * @returns {Array} matching event titles + */ +AfricanAmericanData.searchHistory = async function (titleOrCategory) { + const events = await this._requestData({ + path: `/history/search?q=${encode(titleOrCategory)}`, + }); + return events.map((event) => event.title); +}; + +/** + * Get the title of one random historical event. + * + * @category History + * @returns {String} the random event's title + */ +AfricanAmericanData.getRandomHistoryEvent = async function () { + const event = await this._requestData({ + path: "/history/random", + }); + return event.title || ""; +}; + +/** + * Get historical event titles from a category. + * + * @category History + * @param {String} category history category + * @returns {Array} matching event titles + */ +AfricanAmericanData.getHistoryByCategory = async function (category) { + const events = await this._requestData({ + path: `/history/category/${encode(category)}`, + }); + return events.map((event) => event.title); +}; + +/** + * Get all available history categories. + * + * @category History + * @returns {Array} category names + */ +AfricanAmericanData.getHistoryCategories = async function () { + return this._requestData({ + path: "/history/categories", + }); +}; + +async function lookupHistoryEvent(self, title) { + return self._requestData({ + path: `/history/lookup/${encode(title)}`, + }); +} + +/** + * Get the summary of a historical event. + * + * @category History + * @param {String} title the event's title + * @returns {String} the event summary + */ +AfricanAmericanData.getEventSummary = async function (title) { + const event = await lookupHistoryEvent(this, title); + return event.summary || ""; +}; + +/** + * Get the year of a historical event. + * + * @category History + * @param {String} title the event's title + * @returns {Number} the event year + */ +AfricanAmericanData.getEventYear = async function (title) { + const event = await lookupHistoryEvent(this, title); + return event.year; +}; + +/** + * Get the location of a historical event. + * + * @category History + * @param {String} title the event's title + * @returns {String} the event location + */ +AfricanAmericanData.getEventLocation = async function (title) { + const event = await lookupHistoryEvent(this, title); + return event.location || ""; +}; + +/** + * Get the category of a historical event. + * + * @category History + * @param {String} title the event's title + * @returns {String} the event category + */ +AfricanAmericanData.getEventCategory = async function (title) { + const event = await lookupHistoryEvent(this, title); + return event.category || ""; +}; + +/** + * Get an image for a historical event. + * + * @category History + * @param {String} title the event's title + * @returns {Image} the event image + */ +AfricanAmericanData.getHistoryImage = async function (title) { + const event = await lookupHistoryEvent(this, title); + return this._sendImage({ + baseUrl: event.image, + }); +}; + +// MEDIA +// name, summary, role, image + +/** + * Get the names of all media people. + * + * @category Media + * @returns {Array} all media person names + */ +AfricanAmericanData.getAllMediaPeople = async function () { + const people = await this._requestData({ + path: "/media", + }); + return people.map((person) => person.name); +}; + +/** + * Search media people by name. + * + * @category Media + * @param {String} personName name to search for + * @returns {Array} matching media person names + */ +AfricanAmericanData.searchMediaByName = async function (personName) { + const people = await this._requestData({ + path: `/media/search?q=${encode(personName)}`, + }); + return people.map((person) => person.name); +}; + +/** + * Get the name of one random media person. + * + * @category Media + * @returns {String} the random media person's name + */ +AfricanAmericanData.getRandomMediaPerson = async function () { + const person = await this._requestData({ + path: "/media/random", + }); + return person.name || ""; +}; + +async function lookupMediaPerson(self, name) { + return self._requestData({ + path: `/media/lookup/${encode(name)}`, + }); +} + +/** + * Get a media person's summary. + * + * @category Media + * @param {String} name the media person's name + * @returns {String} the person's summary + */ +AfricanAmericanData.getMediaSummary = async function (name) { + const media = await lookupMediaPerson(this, name); + return media.summary || ""; +}; + +/** + * Get a media person's role. + * + * @category Media + * @param {String} name the media person's name + * @returns {String} the person's role + */ +AfricanAmericanData.getMediaRole = async function (name) { + const media = await lookupMediaPerson(this, name); + return media.role || ""; +}; + +/** + * Get a media person's image. + * + * @category Media + * @param {String} name the media person's name + * @returns {Image} the person's image + */ +AfricanAmericanData.getMediaImage = async function (name) { + const media = await lookupMediaPerson(this, name); + return this._sendImage({ + baseUrl: media.image, + }); +}; + +// CULTURE +// title, category, description, image +/** + * Get the titles of all culture items. + * + * @category Culture + * @returns {Array} all culture item titles + */ +AfricanAmericanData.getAllCultureItems = async function () { + const items = await this._requestData({ + path: "/culture", + }); + return items.map((item) => item.title); +}; + +/** + * Search culture items by title, description, or category. + * + * @category Culture + * @param {String} titleOrDescription search term + * @returns {Array} matching culture item titles + */ +AfricanAmericanData.searchCulture = async function (titleOrDescription) { + const items = await this._requestData({ + path: `/culture/search?q=${encode(titleOrDescription)}`, + }); + return items.map((item) => item.title); +}; + +/** + * Get the title of one random culture item, optionally filtered + * by category. + * + * @category Culture + * @param {String=} category optional culture category to filter by + * @returns {String} the random item's title + */ +AfricanAmericanData.getRandomCultureItem = async function (category) { + const path = category + ? `/culture/random?category=${encode(category)}` + : "/culture/random"; + const item = await this._requestData({ path }); + return item.title || ""; +}; + +/** + * Get culture item titles from a category. + * + * @category Culture + * @param {String} category culture category + * @returns {Array} matching culture item titles + */ +AfricanAmericanData.getCultureByCategory = async function (category) { + const items = await this._requestData({ + path: `/culture/category/${encode(category)}`, + }); + return items.map((item) => item.title); +}; + +/** + * Get all available culture categories. + * + * @category Culture + * @returns {Array} category names + */ +AfricanAmericanData.getCultureCategories = async function () { + return this._requestData({ + path: "/culture/categories", + }); +}; + +async function lookupCultureItem(self, title) { + return self._requestData({ + path: `/culture/lookup/${encode(title)}`, + }); +} + +/** + * Get the category of a culture item. + * + * @category Culture + * @param {String} title the culture item's title + * @returns {String} the item category + */ +AfricanAmericanData.getCultureCategory = async function (title) { + const item = await lookupCultureItem(this, title); + return item.category || ""; +}; + +/** + * Get the description of a culture item. + * + * @category Culture + * @param {String} title the culture item's title + * @returns {String} the item description + */ +AfricanAmericanData.getCultureDescription = async function (title) { + const item = await lookupCultureItem(this, title); + return item.description || ""; +}; + +/** + * Get the image for a culture item. + * + * @category Culture + * @param {String} title the culture item's title + * @returns {Image} the item image + */ +AfricanAmericanData.getCultureImage = async function (title) { + const item = await lookupCultureItem(this, title); + return this._sendImage({ + baseUrl: item.image, + }); +}; + +// COMMUNITY +// Fields: +// name, description, type, city, state, website, image + +/** + * Get the names of all community resources. + * + * @category Community + * @returns {Array} all community resource names + */ +AfricanAmericanData.getAllCommunityResources = async function () { + const resources = await this._requestData({ + path: "/community", + }); + return resources.map((resource) => resource.name); +}; + +/** + * Search community resources by name, type, city, + * state, or description. + * + * @category Community + * @param {String} nameOrDescription search term + * @returns {Array} matching community resource names + */ +AfricanAmericanData.searchCommunity = async function (nameOrDescription) { + const resources = await this._requestData({ + path: `/community/search?q=${encode(nameOrDescription)}`, + }); + return resources.map((resource) => resource.name); +}; + +/** + * Get the name of one random community resource. + * + * @category Community + * @returns {String} the random resource's name + */ +AfricanAmericanData.getRandomCommunityResource = async function () { + const resource = await this._requestData({ + path: "/community/random", + }); + return resource.name || ""; +}; + +/** + * Get community resource names by type. + * + * @category Community + * @param {String} type community resource type + * @returns {Array} matching community resource names + */ +AfricanAmericanData.getCommunityByType = async function (type) { + const resources = await this._requestData({ + path: `/community/type/${encode(type)}`, + }); + return resources.map((resource) => resource.name); +}; + +/** + * Get community resource names by state. + * + * @category Community + * @param {String} state state name + * @returns {Array} matching community resource names + */ +AfricanAmericanData.getCommunityByState = async function (state) { + const resources = await this._requestData({ + path: `/community/state/${encode(state)}`, + }); + return resources.map((resource) => resource.name); +}; + +/** + * Get all available community resource types. + * + * @category Community + * @returns {Array} community resource types + */ +AfricanAmericanData.getCommunityTypes = async function () { + return this._requestData({ + path: "/community/types", + }); +}; + +/** + * Get all represented states. + * + * @category Community + * @returns {Array} state names + */ +AfricanAmericanData.getCommunityStates = async function () { + return this._requestData({ + path: "/community/states", + }); +}; + +async function lookupCommunityResource(self, name) { + return self._requestData({ + path: `/community/lookup/${encode(name)}`, + }); +} + +/** + * Get the description of a community resource. + * + * @category Community + * @param {String} name the resource's name + * @returns {String} the resource description + */ +AfricanAmericanData.getCommunityDescription = async function (name) { + const resource = await lookupCommunityResource(this, name); + return resource.description || ""; +}; + +/** + * Get the type of a community resource. + * + * @category Community + * @param {String} name the resource's name + * @returns {String} the resource type + */ +AfricanAmericanData.getCommunityType = async function (name) { + const resource = await lookupCommunityResource(this, name); + return resource.type || ""; +}; + +/** + * Get the city of a community resource. + * + * @category Community + * @param {String} name the resource's name + * @returns {String} the resource city + */ +AfricanAmericanData.getCommunityCity = async function (name) { + const resource = await lookupCommunityResource(this, name); + return resource.city || ""; +}; + +/** + * Get the state of a community resource. + * + * @category Community + * @param {String} name the resource's name + * @returns {String} the resource state + */ +AfricanAmericanData.getCommunityState = async function (name) { + const resource = await lookupCommunityResource(this, name); + return resource.state || ""; +}; + +/** + * Get the website of a community resource. + * + * @category Community + * @param {String} name the resource's name + * @returns {String} the resource website + */ +AfricanAmericanData.getCommunityWebsite = async function (name) { + const resource = await lookupCommunityResource(this, name); + return resource.website || ""; +}; + +/** + * Get the image for a community resource. + * + * @category Community + * @param {String} name the resource's name + * @returns {Image} the resource image + */ +AfricanAmericanData.getCommunityImage = async function (name) { + const resource = await lookupCommunityResource(this, name); + return this._sendImage({ + baseUrl: resource.image, + }); +}; + +module.exports = AfricanAmericanData; \ No newline at end of file From de7443dd930b6b09ab1b1e89cb5f7b9600db3dc4 Mon Sep 17 00:00:00 2001 From: Format Bot Date: Mon, 27 Jul 2026 19:49:35 +0000 Subject: [PATCH 8/8] Fix code formatting --- .../african-american-data.js | 118 +++++++++--------- .../african-american-data/data/index.js | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/procedures/african-american-data/african-american-data.js b/src/procedures/african-american-data/african-american-data.js index 2051a91a..0bc8025b 100644 --- a/src/procedures/african-american-data/african-american-data.js +++ b/src/procedures/african-american-data/african-american-data.js @@ -7,27 +7,27 @@ * @service * @category History */ - + const ApiConsumer = require("../utils/api-consumer"); - + const BASE_URL = "http://flask-api-env.eba-er3e5y3h.us-east-2.elasticbeanstalk.com/api"; - + const AfricanAmericanData = new ApiConsumer( "AfricanAmericanData", BASE_URL, { cache: { ttl: 5 * 60 }, - } + }, ); - + function encode(value) { return encodeURIComponent(String(value || "").trim()); } - // PEOPLE +// PEOPLE // Fields: // name, achievement, occupation, category, image - + /** * Get the names of all people. * @@ -40,7 +40,7 @@ AfricanAmericanData.getAllPeople = async function () { }); return people.map((person) => person.name); }; - + /** * Search people by name, occupation, achievement, or category. * @@ -54,7 +54,7 @@ AfricanAmericanData.searchPeople = async function (nameOrFieldOrCategory) { }); return people.map((person) => person.name); }; - + /** * Get the name of one random person. * @@ -80,7 +80,7 @@ AfricanAmericanData.getPeopleByCategory = async function (category) { path: `/people/category/${encode(category)}`, }); }; - + /** * Get all available people categories. * @@ -92,7 +92,7 @@ AfricanAmericanData.getPeopleCategories = async function () { path: "/people/categories", }); }; - + async function lookupPerson(self, name) { return self._requestData({ path: `/people/lookup/${encode(name)}`, @@ -110,7 +110,7 @@ AfricanAmericanData.getPersonAchievement = async function (name) { const person = await lookupPerson(this, name); return person.achievement || ""; }; - + /** * Get a person's occupation. * @@ -122,7 +122,7 @@ AfricanAmericanData.getPersonOccupation = async function (name) { const person = await lookupPerson(this, name); return person.occupation || ""; }; - + /** * Get a person's category. * @@ -134,7 +134,7 @@ AfricanAmericanData.getPersonCategory = async function (name) { const person = await lookupPerson(this, name); return person.category || ""; }; - + /** * Get a person's image. * @@ -148,10 +148,10 @@ AfricanAmericanData.getPersonImage = async function (name) { baseUrl: person.image, }); }; - + // HISTORY // title, summary, year, location, category, image - + /** * Get the titles of all historical events. * @@ -164,7 +164,7 @@ AfricanAmericanData.getAllHistoryEvents = async function () { }); return events.map((event) => event.title); }; - + /** * Search historical events by title, summary, location, * year, or category. @@ -179,7 +179,7 @@ AfricanAmericanData.searchHistory = async function (titleOrCategory) { }); return events.map((event) => event.title); }; - + /** * Get the title of one random historical event. * @@ -192,7 +192,7 @@ AfricanAmericanData.getRandomHistoryEvent = async function () { }); return event.title || ""; }; - + /** * Get historical event titles from a category. * @@ -206,7 +206,7 @@ AfricanAmericanData.getHistoryByCategory = async function (category) { }); return events.map((event) => event.title); }; - + /** * Get all available history categories. * @@ -224,7 +224,7 @@ async function lookupHistoryEvent(self, title) { path: `/history/lookup/${encode(title)}`, }); } - + /** * Get the summary of a historical event. * @@ -236,7 +236,7 @@ AfricanAmericanData.getEventSummary = async function (title) { const event = await lookupHistoryEvent(this, title); return event.summary || ""; }; - + /** * Get the year of a historical event. * @@ -248,7 +248,7 @@ AfricanAmericanData.getEventYear = async function (title) { const event = await lookupHistoryEvent(this, title); return event.year; }; - + /** * Get the location of a historical event. * @@ -260,7 +260,7 @@ AfricanAmericanData.getEventLocation = async function (title) { const event = await lookupHistoryEvent(this, title); return event.location || ""; }; - + /** * Get the category of a historical event. * @@ -272,7 +272,7 @@ AfricanAmericanData.getEventCategory = async function (title) { const event = await lookupHistoryEvent(this, title); return event.category || ""; }; - + /** * Get an image for a historical event. * @@ -286,10 +286,10 @@ AfricanAmericanData.getHistoryImage = async function (title) { baseUrl: event.image, }); }; - + // MEDIA // name, summary, role, image - + /** * Get the names of all media people. * @@ -302,7 +302,7 @@ AfricanAmericanData.getAllMediaPeople = async function () { }); return people.map((person) => person.name); }; - + /** * Search media people by name. * @@ -316,7 +316,7 @@ AfricanAmericanData.searchMediaByName = async function (personName) { }); return people.map((person) => person.name); }; - + /** * Get the name of one random media person. * @@ -329,13 +329,13 @@ AfricanAmericanData.getRandomMediaPerson = async function () { }); return person.name || ""; }; - + async function lookupMediaPerson(self, name) { return self._requestData({ path: `/media/lookup/${encode(name)}`, }); } - + /** * Get a media person's summary. * @@ -347,7 +347,7 @@ AfricanAmericanData.getMediaSummary = async function (name) { const media = await lookupMediaPerson(this, name); return media.summary || ""; }; - + /** * Get a media person's role. * @@ -359,7 +359,7 @@ AfricanAmericanData.getMediaRole = async function (name) { const media = await lookupMediaPerson(this, name); return media.role || ""; }; - + /** * Get a media person's image. * @@ -373,9 +373,9 @@ AfricanAmericanData.getMediaImage = async function (name) { baseUrl: media.image, }); }; - + // CULTURE -// title, category, description, image +// title, category, description, image /** * Get the titles of all culture items. * @@ -388,7 +388,7 @@ AfricanAmericanData.getAllCultureItems = async function () { }); return items.map((item) => item.title); }; - + /** * Search culture items by title, description, or category. * @@ -402,7 +402,7 @@ AfricanAmericanData.searchCulture = async function (titleOrDescription) { }); return items.map((item) => item.title); }; - + /** * Get the title of one random culture item, optionally filtered * by category. @@ -418,7 +418,7 @@ AfricanAmericanData.getRandomCultureItem = async function (category) { const item = await this._requestData({ path }); return item.title || ""; }; - + /** * Get culture item titles from a category. * @@ -432,7 +432,7 @@ AfricanAmericanData.getCultureByCategory = async function (category) { }); return items.map((item) => item.title); }; - + /** * Get all available culture categories. * @@ -444,13 +444,13 @@ AfricanAmericanData.getCultureCategories = async function () { path: "/culture/categories", }); }; - + async function lookupCultureItem(self, title) { return self._requestData({ path: `/culture/lookup/${encode(title)}`, }); } - + /** * Get the category of a culture item. * @@ -462,7 +462,7 @@ AfricanAmericanData.getCultureCategory = async function (title) { const item = await lookupCultureItem(this, title); return item.category || ""; }; - + /** * Get the description of a culture item. * @@ -474,7 +474,7 @@ AfricanAmericanData.getCultureDescription = async function (title) { const item = await lookupCultureItem(this, title); return item.description || ""; }; - + /** * Get the image for a culture item. * @@ -488,11 +488,11 @@ AfricanAmericanData.getCultureImage = async function (title) { baseUrl: item.image, }); }; - + // COMMUNITY // Fields: // name, description, type, city, state, website, image - + /** * Get the names of all community resources. * @@ -505,7 +505,7 @@ AfricanAmericanData.getAllCommunityResources = async function () { }); return resources.map((resource) => resource.name); }; - + /** * Search community resources by name, type, city, * state, or description. @@ -520,7 +520,7 @@ AfricanAmericanData.searchCommunity = async function (nameOrDescription) { }); return resources.map((resource) => resource.name); }; - + /** * Get the name of one random community resource. * @@ -533,7 +533,7 @@ AfricanAmericanData.getRandomCommunityResource = async function () { }); return resource.name || ""; }; - + /** * Get community resource names by type. * @@ -547,7 +547,7 @@ AfricanAmericanData.getCommunityByType = async function (type) { }); return resources.map((resource) => resource.name); }; - + /** * Get community resource names by state. * @@ -561,7 +561,7 @@ AfricanAmericanData.getCommunityByState = async function (state) { }); return resources.map((resource) => resource.name); }; - + /** * Get all available community resource types. * @@ -573,7 +573,7 @@ AfricanAmericanData.getCommunityTypes = async function () { path: "/community/types", }); }; - + /** * Get all represented states. * @@ -591,7 +591,7 @@ async function lookupCommunityResource(self, name) { path: `/community/lookup/${encode(name)}`, }); } - + /** * Get the description of a community resource. * @@ -603,7 +603,7 @@ AfricanAmericanData.getCommunityDescription = async function (name) { const resource = await lookupCommunityResource(this, name); return resource.description || ""; }; - + /** * Get the type of a community resource. * @@ -615,7 +615,7 @@ AfricanAmericanData.getCommunityType = async function (name) { const resource = await lookupCommunityResource(this, name); return resource.type || ""; }; - + /** * Get the city of a community resource. * @@ -627,7 +627,7 @@ AfricanAmericanData.getCommunityCity = async function (name) { const resource = await lookupCommunityResource(this, name); return resource.city || ""; }; - + /** * Get the state of a community resource. * @@ -639,7 +639,7 @@ AfricanAmericanData.getCommunityState = async function (name) { const resource = await lookupCommunityResource(this, name); return resource.state || ""; }; - + /** * Get the website of a community resource. * @@ -651,7 +651,7 @@ AfricanAmericanData.getCommunityWebsite = async function (name) { const resource = await lookupCommunityResource(this, name); return resource.website || ""; }; - + /** * Get the image for a community resource. * @@ -665,5 +665,5 @@ AfricanAmericanData.getCommunityImage = async function (name) { baseUrl: resource.image, }); }; - -module.exports = AfricanAmericanData; \ No newline at end of file + +module.exports = AfricanAmericanData; diff --git a/src/procedures/african-american-data/data/index.js b/src/procedures/african-american-data/data/index.js index c9fd79d7..abf4e457 100644 --- a/src/procedures/african-american-data/data/index.js +++ b/src/procedures/african-american-data/data/index.js @@ -98,4 +98,4 @@ async function getData() { module.exports = { getData, -}; \ No newline at end of file +};