From e3e49640c288050c80da0cf17f961c8bd839738b Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Thu, 20 Jun 2024 14:39:37 +0300 Subject: [PATCH 1/4] Display all tools --- .../components/Tool/DescriptionAndShare.js | 26 ++++---- .../src/components/Tool/Metrics.js | 7 +- .../Tool/OrgThemeAndOperatingCountries.js | 8 +-- .../charterafrica/src/components/Tool/Tool.js | 64 ++++++++++--------- .../src/components/Tool/Tool.snap.js | 35 +--------- .../src/lib/ecosystem/airtable/processData.js | 5 -- .../src/lib/ecosystem/github/processData.js | 3 + 7 files changed, 62 insertions(+), 86 deletions(-) diff --git a/apps/charterafrica/src/components/Tool/DescriptionAndShare.js b/apps/charterafrica/src/components/Tool/DescriptionAndShare.js index cd49706b6..651c7d9d5 100644 --- a/apps/charterafrica/src/components/Tool/DescriptionAndShare.js +++ b/apps/charterafrica/src/components/Tool/DescriptionAndShare.js @@ -18,18 +18,20 @@ const DescriptionAndShare = React.forwardRef( > {description} - - {activeText} {lastActive} - + {lastActive ? ( + + {activeText} {lastActive} + + ) : null} diff --git a/apps/charterafrica/src/components/Tool/OrgThemeAndOperatingCountries.js b/apps/charterafrica/src/components/Tool/OrgThemeAndOperatingCountries.js index 93734db76..6aa038f1b 100644 --- a/apps/charterafrica/src/components/Tool/OrgThemeAndOperatingCountries.js +++ b/apps/charterafrica/src/components/Tool/OrgThemeAndOperatingCountries.js @@ -8,7 +8,7 @@ const OrgThemeAndOperatingCountries = React.forwardRef( function OrgThemeAndOperatingCountries(props, ref) { const { sx, organisation, theme, operatingCountries } = props; const countries = operatingCountries?.join(", "); - if (!organisation) { + if (!organisation && !theme) { return null; } return ( @@ -25,8 +25,8 @@ const OrgThemeAndOperatingCountries = React.forwardRef( >
- {organisation.name} + {organisation?.name} - + > + + {goToRepo?.label} + + ) : null} - - - {collectionText} - - - {classification} - - + {classification ? ( + + + {collectionText} + + + {classification} + + + ) : null} renders unchanged 1`] = ` />
-
- 0 -
-
+ />
renders unchanged 1`] = ` />
-
- 0 -
-
+ />
renders unchanged 1`] = ` >
- -
-
{ diff --git a/apps/charterafrica/src/lib/ecosystem/github/processData.js b/apps/charterafrica/src/lib/ecosystem/github/processData.js index 000299153..62fb75c3e 100644 --- a/apps/charterafrica/src/lib/ecosystem/github/processData.js +++ b/apps/charterafrica/src/lib/ecosystem/github/processData.js @@ -80,6 +80,9 @@ function fetchUserQuery(username) { } export async function fetchTool({ externalId }) { + if (!externalId) { + return null; + } let [repositoryOwner, repositoryName] = externalId .replace(/^https?:\/\/github\.com\//, "") .replace(/\/$/, "") From ff2d8f4599f00edd626612cfa168fa7257229183 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Fri, 21 Jun 2024 12:32:37 +0300 Subject: [PATCH 2/4] Do not process missing tool name --- .../charterafrica/src/lib/ecosystem/airtable/processData.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/charterafrica/src/lib/ecosystem/airtable/processData.js b/apps/charterafrica/src/lib/ecosystem/airtable/processData.js index 030b3c210..c8736cf1a 100644 --- a/apps/charterafrica/src/lib/ecosystem/airtable/processData.js +++ b/apps/charterafrica/src/lib/ecosystem/airtable/processData.js @@ -70,6 +70,12 @@ export function processTool(item, config, { partnersData }) { } = config; const data = { ...item.fields, id: item.id }; const externalId = getValue(data, toolTableColumns.slug)?.trim(); + const toolName = getValue(data, toolTableColumns.name)?.trim(); + if (!toolName) { + const message = `Missing name for Tool ${data.id}. Skipping`; + Sentry.captureMessage(message); + return null; + } const locales = localized ? ["en", "fr", "pt"] : ["en"]; const foundTheme = locales.reduce((acc, curr) => { From 0d0e40bd429ca99f2875487f04fb41bc414d4383 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Fri, 21 Jun 2024 14:21:31 +0300 Subject: [PATCH 3/4] Updated last active --- .../components/Tool/DescriptionAndShare.js | 27 +++++++++---------- .../src/components/Tool/Tool.snap.js | 3 +-- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/apps/charterafrica/src/components/Tool/DescriptionAndShare.js b/apps/charterafrica/src/components/Tool/DescriptionAndShare.js index 651c7d9d5..a10f5b7b6 100644 --- a/apps/charterafrica/src/components/Tool/DescriptionAndShare.js +++ b/apps/charterafrica/src/components/Tool/DescriptionAndShare.js @@ -8,6 +8,7 @@ import ShareThisPage from "@/charterafrica/components/ShareThisPage"; const DescriptionAndShare = React.forwardRef( function DescriptionAndShare(props, ref) { const { sx, description, lastActive, activeText } = props; + const lastActiveText = lastActive ? `${activeText} ${lastActive}` : null; return ( {description} - {lastActive ? ( - - {activeText} {lastActive} - - ) : null} + + {lastActiveText} + renders unchanged 1`] = `
- - 6 Months ago + undefined 6 Months ago
Date: Thu, 27 Jun 2024 11:55:33 +0300 Subject: [PATCH 4/4] Ensure key fields exist --- .../src/lib/ecosystem/airtable/processData.js | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/apps/charterafrica/src/lib/ecosystem/airtable/processData.js b/apps/charterafrica/src/lib/ecosystem/airtable/processData.js index c8736cf1a..3637a75ab 100644 --- a/apps/charterafrica/src/lib/ecosystem/airtable/processData.js +++ b/apps/charterafrica/src/lib/ecosystem/airtable/processData.js @@ -20,6 +20,16 @@ function getSourceType(link) { return "github"; } +function checkFields(obj) { + const emptyFields = Object.keys(obj) + .map((field) => (!obj[field] ? field : null)) + .filter(Boolean); + if (emptyFields.length > 0) { + return `The following fields are missing ${emptyFields.join(", ")}`; + } + return null; +} + function getRepoLink(source = "github", slug = "") { if (source === "github" && slug) { return `https://github.com/${slug}`; @@ -70,8 +80,8 @@ export function processTool(item, config, { partnersData }) { } = config; const data = { ...item.fields, id: item.id }; const externalId = getValue(data, toolTableColumns.slug)?.trim(); - const toolName = getValue(data, toolTableColumns.name)?.trim(); - if (!toolName) { + const name = getValue(data, toolTableColumns.name)?.trim(); + if (!name) { const message = `Missing name for Tool ${data.id}. Skipping`; Sentry.captureMessage(message); return null; @@ -116,12 +126,28 @@ export function processTool(item, config, { partnersData }) { data, ); const source = getSourceType(getValue(data, toolTableColumns.source.url)); + const avatarUrl = + getValue(data, toolTableColumns.avatarUrl)?.[0]?.url ?? null; + const fieldsToCheck = { + avatarUrl, + name, + description, + operatingCountries, + theme, + }; + const missingFields = checkFields(fieldsToCheck); + if (missingFields) { + const message = `Tool ${name}: ${missingFields}`; + Sentry.captureMessage(message); + return null; + } + return { airtableId: data.id, - avatarUrl: getValue(data, toolTableColumns.avatarUrl)?.[0]?.url ?? null, + avatarUrl, externalId, repoLink: getValue(data, toolTableColumns.source.url), - name: getValue(data, toolTableColumns.name), + name, link: getValue(data, toolTableColumns.url), operatingCountries, contributors: getValue(data, toolTableColumns.contributors),