Skip to content

Commit ab22d76

Browse files
authored
feat: add country-to-continent mapping for issue labels (#1477)
* Add country-to-continent mapping for issue labels Country to Continent mapping found here: https://gist.github.com/stevewithington/20a69c0b6d2ff846ea5d35e5fc47f26c Addressing MobilityData/mobility-database-catalogs#1005 * update: with commas * update: colons * update: indent * update: to remove trailing whitespace, duplicate countries * update: to use countries-list ts library for country-continent mapping * update: with logging library * fix: linter errors * fix: linter errors * chore: add countries-list dependency * fix: to address review comments
1 parent a0f0896 commit ab22d76

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

functions/packages/feed-form/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"main": "lib/index.js",
1919
"dependencies": {
2020
"axios": "^1.7.7",
21+
"countries-list": "^3.2.0",
2122
"firebase": "^10.6.0",
2223
"firebase-admin": "^11.8.0",
2324
"firebase-functions": "^4.3.1",

functions/packages/feed-form/src/impl/feed-form-impl.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as logger from "firebase-functions/logger";
44
import {type FeedSubmissionFormRequestBody} from "./types";
55
import {type CallableRequest, HttpsError} from "firebase-functions/v2/https";
66
import axios from "axios";
7+
import {countries, continents, type TCountryCode} from "countries-list";
78

89
const SCOPES = [
910
"https://www.googleapis.com/auth/spreadsheets",
@@ -321,13 +322,21 @@ async function createGithubIssue(
321322
issueTitle += " - Official Feed";
322323
}
323324
const issueBody = buildGithubIssueBody(formData, spreadsheetId);
325+
326+
const labels = ["feed submission"];
327+
if (formData.country && formData.country in countries) {
328+
const country = countries[formData.country as TCountryCode];
329+
const continent = continents[country.continent].toLowerCase();
330+
if (continent != null) labels.push(continent);
331+
}
332+
324333
try {
325334
const response = await axios.post(
326335
githubRepoUrlIssue,
327336
{
328337
title: issueTitle,
329338
body: issueBody,
330-
labels: ["feed submission"],
339+
labels,
331340
},
332341
{
333342
headers: {

0 commit comments

Comments
 (0)