Skip to content

Commit

Permalink
chore: remove legacy weather resources
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismclarke committed Feb 27, 2025
1 parent d08cea8 commit d8f427b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 41 deletions.
2 changes: 0 additions & 2 deletions apps/picsa-tools/resources-tool/src/app/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import { IResourceBase } from '../schemas/base';
import CROPS from './crops';
import { GENDER_RESOURCES } from './gender';
import PICSA_RESOURCES from './picsa';
import WEATHER from './weather';

const byId: Record<string, IResourceBase> = {
...CROPS,
...GENDER_RESOURCES,
...WEATHER,
...PICSA_RESOURCES,
};

Expand Down
16 changes: 0 additions & 16 deletions apps/picsa-tools/resources-tool/src/app/data/weather/files.ts

This file was deleted.

28 changes: 5 additions & 23 deletions apps/picsa-tools/resources-tool/src/app/data/weather/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { FORECAST_COLLECTIONS, FORECAST_FILES } from '@picsa/data/resources/forecasts';

import { IResourceCollection, IResourceFile, IResourceLink } from '../../schemas';
import { filterHashmap } from '../../utils/data.utils';
import weatherFiles from './files';
import { IResourceCollection, IResourceLink } from '../../schemas';
import { WEATHER_LINKS } from './links';
import { IWeatherLocation } from './locations';
import { MeteoBlueGenerator } from './meteoBlue';
Expand All @@ -29,26 +25,18 @@ const weatherResources: IResourceCollection = {
id: 'weatherResources',
type: 'collection',
title: 'Weather Resources',
// TODO - add support for including direct link to app page instead of collection
description: 'Local forecasts and meterological services',
cover: { image: 'assets/resources/covers/weather.svg' },
priority: 6,
childResources: {
// collections: WEATHER_LOCATIONS.map((location) => `weatherResources_${location.id}`),
collections: [FORECAST_COLLECTIONS.forecasts_downscaled.id],
files: FORECAST_COLLECTIONS.forecasts.childResources.files,
links: Object.keys(WEATHER_LINKS),
},
childResources: { collections: [], files: [], links: [] },
};

function generateLocationResources(location: IWeatherLocation) {
const links: Record<string, IResourceLink> = {
...new WMOGenerator(location).links,
...new MeteoBlueGenerator(location).links,
};
const forecasts = { ...weatherFiles.downscaledForecasts, ...weatherFiles.otherForecasts };
const files: Record<string, IResourceFile> = {
...filterHashmap(forecasts, (r) => r.meta.locationIds.includes(location.id)),
};

const collection: IResourceCollection = {
id: `weatherResources_${location.id}`,
Expand All @@ -59,27 +47,21 @@ function generateLocationResources(location: IWeatherLocation) {
parentCollection: 'weatherResources',
childResources: {
collections: [],
files: Object.keys(files),
files: [],
links: Object.keys(links),
},
filter: { countries: [location.countryCode] },
};
return {
[collection.id]: collection,
...links,
...files,
};
}

// HACK - only included downscaled collection (files from main collection included in web)
const { forecasts_downscaled } = FORECAST_COLLECTIONS;
// const { forecasts_downscaled } = FORECAST_COLLECTIONS;

export default {
weatherResources,
...WEATHER_LINKS,
// ...localisedResources,
...weatherFiles.downscaledForecasts,
...weatherFiles.otherForecasts,
forecasts_downscaled,
...FORECAST_FILES,
};

0 comments on commit d8f427b

Please sign in to comment.