Skip to content

Commit b6e29d5

Browse files
committed
feat: add terminology config options
1 parent 377e4f5 commit b6e29d5

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,7 @@ Currently, the game exclusively accommodates exactly two locations. You have the
180180
:warning: **Please exercise caution and refrain from modifying the "location_code" fields. Altering the default values ('hq', 'local') here can disrupt the application's functionality!** :warning:
181181

182182
Changing the names of the locations in this section will solely impact how they are displayed in the header menu, tabs, and action titles. Role names (e.g., "HQ IT Team") remain distinct and should be configured separately within the **ROLES** table.
183+
184+
## DICTIONARY
185+
186+
You have the ability to modify the terminology associated with "polls" in this section. For instance, you can replace "poll" or "budget" with alternative words. To introduce a new synonym, simply edit the synonym column as needed.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
exports.up = async (knex) => {
2+
await knex.schema.createTable('dictionary', (tbl) => {
3+
tbl.string('id').primary().notNullable();
4+
tbl.string('word').notNullable();
5+
tbl.string('synonym').notNullable();
6+
});
7+
};
8+
9+
exports.down = async (knex) => {
10+
await knex.schema.dropTableIfExists('dictionary');
11+
};

src/app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ app.get('/locations', async (req, res) => {
5050
res.json(records);
5151
});
5252

53+
app.get('/dictionary', async (req, res) => {
54+
const records = await db('dictionary').select('word', 'synonym');
55+
res.json(records);
56+
});
57+
5358
app.get('/systems', async (req, res) => {
5459
const records = await db('system');
5560
res.json(records);

src/util/migrate.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ async function migrate(accessToken, baseId) {
9595
fetchTable(base, 'event_types'),
9696
// fetch main tables
9797
fetchTable(base, 'locations'),
98+
fetchTable(base, 'dictionary'),
9899
fetchTable(base, 'events'),
99100
fetchTable(base, 'purchased_mitigations'),
100101
fetchTable(base, 'responses'),
@@ -115,6 +116,7 @@ async function migrate(accessToken, baseId) {
115116
rawRecommendations,
116117
rawEventTypes,
117118
locations,
119+
dictionary,
118120
injections, // = events
119121
mitigations, // = purchased_mitigations
120122
responses,
@@ -224,6 +226,7 @@ async function migrate(accessToken, baseId) {
224226
// sequential processing is important here as some tables rely on data from other tables to be already there
225227
const validatedSqlTables = await Promise.allSettled([
226228
validateForDb('location', locations),
229+
validateForDb('dictionary', dictionary),
227230
validateForDb('injection', injections),
228231
validateForDb('mitigation', mitigations),
229232
validateForDb('response', responses),
@@ -242,6 +245,7 @@ async function migrate(accessToken, baseId) {
242245

243246
const [
244247
sqlLocations,
248+
sqlDictionary,
245249
sqlInjections,
246250
sqlMitigations,
247251
sqlResponses,
@@ -254,6 +258,7 @@ async function migrate(accessToken, baseId) {
254258
] = validatedSqlTables.map((table) => table.value);
255259

256260
await saveToDb('location', sqlLocations);
261+
await saveToDb('dictionary', sqlDictionary);
257262
await saveToDb('injection', sqlInjections);
258263
await saveToDb('mitigation', sqlMitigations);
259264
await saveToDb('response', sqlResponses);

src/util/migration_schemas.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ const airtableSchemas = {
2626
name: yup.string(),
2727
location_code: yup.string().required().oneOf(locationsShort),
2828
}),
29+
dictionary: yup.object({
30+
id,
31+
word: yup.string().required(),
32+
synonym: yup.string().required(),
33+
}),
2934
recommendations: yup.object({
3035
id,
3136
name: yup.string(),
@@ -139,6 +144,11 @@ const dbSchemas = {
139144
name: yup.string().required(),
140145
type: yup.string().oneOf(locationsShort).required(),
141146
}),
147+
dictionary: yup.object({
148+
id,
149+
word: yup.string().required(),
150+
synonym: yup.string().required(),
151+
}),
142152
action: yup.object({
143153
id,
144154
description: yup.string().required(),

0 commit comments

Comments
 (0)