Skip to content

Commit

Permalink
Merge pull request #33 from concord-consortium/186924285-is-active-le…
Browse files Browse the repository at this point in the history
…gend

Fixes isActive formula
  • Loading branch information
eireland authored Jan 29, 2024
2 parents 23a9739 + 94ddbb1 commit fc14888
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { AttributeFilter } from "./attribute-filter";
import { InfoModal } from "./info-modal";
import { useStateContext } from "../hooks/use-state";
import { adjustStationDataset, getWeatherStations } from "../utils/getWeatherStations";
import { addNotificationHandler, createStationsDataset } from "../utils/codapHelpers";
import { addNotificationHandler, createStationsDataset, guaranteeGlobal } from "../utils/codapHelpers";
import InfoIcon from "../assets/images/icon-info.svg";
import { useCODAPApi } from "../hooks/use-codap-api";
import { composeURL, formatData } from "../utils/noaaApiHelper";
import { StationDSName } from "../constants";
import { IDataType } from "../types";

Check warning on line 14 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / Build & Run Tests

'IDataType' is defined but never used

Check warning on line 14 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / Build & Run Tests

'IDataType' is defined but never used

Check warning on line 14 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / Build & Run Tests

'IDataType' is defined but never used

Check warning on line 14 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / S3 Deploy

'IDataType' is defined but never used

Check warning on line 14 in src/components/App.tsx

View workflow job for this annotation

GitHub Actions / S3 Deploy

'IDataType' is defined but never used
import { StationDSName, globalMaxDate, globalMinDate } from "../constants";
import { geoLocSearch } from "../utils/geonameSearch";
import { DataReturnWarning } from "./data-return-warning";

Expand All @@ -35,7 +36,6 @@ export const App = () => {
useEffect(() => {
initializePlugin({pluginName: kPluginName, version: kVersion, dimensions: kInitialDimensions});


const stationSelectionHandler = async(req: any) =>{
if (req.values.operation === "selectCases") {
const result = req.values.result;
Expand All @@ -62,9 +62,13 @@ export const App = () => {
}, []);

useEffect(() => {
const minDate = state.startDate || new Date( -5364662060);
const maxDate = state.endDate || new Date(Date.now());
adjustStationDataset(weatherStations); //change max data to "present"
createStationsDataset(weatherStations); //send weather station data to CODAP
},[weatherStations]);
guaranteeGlobal(globalMinDate, Number(minDate)/1000);
guaranteeGlobal(globalMaxDate, Number(maxDate)/1000);
},[state.endDate, state.startDate, weatherStations]);

const handleOpenInfo = () => {
setState(draft => {
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const kWeatherStationCollectionAttrs = [
name: "isActive",
formula: `(number(maxdate="present"
? date()
: date(split(maxdate,'-',1), split(maxdate, ""-", 2), split(maxdate, "-", 3))) - wxMinDate)>0 and wxMaxDate-number(date(split(mindate,"-",1), split(mindate, "-", 2), split(mindate, "-", 3)))>0`,
: date(split(maxdate,'-',1), split(maxdate, "-", 2), split(maxdate, "-", 3))) - wxMinDate)>0 and wxMaxDate-number(date(split(mindate,"-",1), split(mindate, "-", 2), split(mindate, "-", 3)))>0`,
description: "whether the station was active in the Weather Plugin's requested date range",
_categoryMap: {
__order: [
Expand Down

0 comments on commit fc14888

Please sign in to comment.