From 80c6af3cfa2dce2526bc6843959b6247b34bc11f Mon Sep 17 00:00:00 2001 From: ritvje Date: Sun, 17 Jul 2016 10:50:18 +0300 Subject: [PATCH 1/4] While creating selections handle only extra selections that have extra selection group --- src/kuksa-integration/rebuild-tables.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kuksa-integration/rebuild-tables.js b/src/kuksa-integration/rebuild-tables.js index f8fb4b2d..d68445d8 100644 --- a/src/kuksa-integration/rebuild-tables.js +++ b/src/kuksa-integration/rebuild-tables.js @@ -192,6 +192,7 @@ function buildSelectionTable() { .then(participants => Promise.each(participants, p => findKuksaParticipantExtraSelections({ where: { participantId: p.participantId }, include: { selection: 'group' } }) .then(participantSelections => participantSelections.map(selections => selections.toObject())) + .then(participantSelections => _.filter(participantSelections, s => !!s.group)) // Apparently some selections don't have a group, so handle only selections with group .then(participantSelections => _.filter(participantSelections, s => (_.indexOf(groupsToCreate, s.selection.group.name) > -1))) .then(participantSelections => participantSelections.map(sel => ({ participantId: sel.participantId, From 8cd2130a5732a7acaac033cc88581d5af3bf9cc4 Mon Sep 17 00:00:00 2001 From: ritvje Date: Sun, 17 Jul 2016 11:43:13 +0300 Subject: [PATCH 2/4] =?UTF-8?q?Add=20accommodation=20to=20participant=20&?= =?UTF-8?q?=20if=20it's=20'Perheleiriss=C3=A4',=20set=20subCamp=20as=20'Ri?= =?UTF-8?q?ehu'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/models/kuksa-participant.json | 12 ++++++++++++ src/common/models/participant.json | 12 ++++++++++++ src/kuksa-integration/fetch-data.js | 1 + src/kuksa-integration/rebuild-tables.js | 5 ++++- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/common/models/kuksa-participant.json b/src/common/models/kuksa-participant.json index ab19796e..77f86e8d 100644 --- a/src/common/models/kuksa-participant.json +++ b/src/common/models/kuksa-participant.json @@ -146,6 +146,18 @@ "nullable": "YES" } }, + "accommodation": { + "type": "string", + "required": false, + "postgresql": { + "columnName": "accommodation", + "dataType": "character varying", + "dataLength": 255, + "dataPrecision": null, + "dataScale": null, + "nullable": "YES" + } + }, "cancelled": { "type": "boolean", "postgresql": { diff --git a/src/common/models/participant.json b/src/common/models/participant.json index d30a1cb7..c92a130c 100644 --- a/src/common/models/participant.json +++ b/src/common/models/participant.json @@ -256,6 +256,18 @@ "nullable": "NO" } }, + "accommodation": { + "type": "string", + "required": false, + "postgresql": { + "columnName": "accommodation", + "dataType": "character varying", + "dataLength": 255, + "dataPrecision": null, + "dataScale": null, + "nullable": "YES" + } + }, "ageGroup": { "type": "string", "required": true, diff --git a/src/kuksa-integration/fetch-data.js b/src/kuksa-integration/fetch-data.js index 1ed7ca59..7c5e6161 100644 --- a/src/kuksa-integration/fetch-data.js +++ b/src/kuksa-integration/fetch-data.js @@ -137,6 +137,7 @@ function transferParticipants(eventApi) { subCampId: participant.subCamp, cancelled: participant.cancelled, diet: participant.diet, + accommodation: participant.accommodation, }), dateRange: daterange, }, diff --git a/src/kuksa-integration/rebuild-tables.js b/src/kuksa-integration/rebuild-tables.js index d68445d8..01a9a9f3 100644 --- a/src/kuksa-integration/rebuild-tables.js +++ b/src/kuksa-integration/rebuild-tables.js @@ -61,7 +61,9 @@ function rebuildParticipantsTable() { } function getSubCamp(participant) { - if (getSelectionForGroup(participant, 'Osallistun seuraavan ikäkauden ohjelmaan:') === 'perheleirin ohjelmaan (0-11v.), muistathan merkitä lisätiedot osallistumisesta \"vain perheleirin osallistujille\" -osuuteen.') { + if (participant.accommodation === 'Perheleirissä') { + return 'Riehu'; + } else if (getSelectionForGroup(participant, 'Osallistun seuraavan ikäkauden ohjelmaan:') === 'perheleirin ohjelmaan (0-11v.), muistathan merkitä lisätiedot osallistumisesta \"vain perheleirin osallistujille\" -osuuteen.') { return 'Riehu'; } return _.get(participant, 'subCamp.name') || 'Muu'; @@ -94,6 +96,7 @@ function rebuildParticipantsTable() { email: participant.email, internationalGuest: !!participant.localGroup, diet: participant.diet, + accommodation: participant.accommodation, localGroup: participant.representedParty || _.get(participant, 'localGroup.name') || 'Muu', campGroup: _.get(participant, 'campGroup.name') || 'Muu', subCamp: getSubCamp(participant), From d0a2ce0095367e6333b865d816e95dca404d0265 Mon Sep 17 00:00:00 2001 From: ritvje Date: Sun, 17 Jul 2016 11:51:38 +0300 Subject: [PATCH 3/4] Fix bad filter function --- src/kuksa-integration/rebuild-tables.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kuksa-integration/rebuild-tables.js b/src/kuksa-integration/rebuild-tables.js index 01a9a9f3..7caae9e0 100644 --- a/src/kuksa-integration/rebuild-tables.js +++ b/src/kuksa-integration/rebuild-tables.js @@ -195,7 +195,7 @@ function buildSelectionTable() { .then(participants => Promise.each(participants, p => findKuksaParticipantExtraSelections({ where: { participantId: p.participantId }, include: { selection: 'group' } }) .then(participantSelections => participantSelections.map(selections => selections.toObject())) - .then(participantSelections => _.filter(participantSelections, s => !!s.group)) // Apparently some selections don't have a group, so handle only selections with group + .then(participantSelections => _.filter(participantSelections, s => !!s.selection.group)) // Apparently some selections don't have a group, so handle only selections with group .then(participantSelections => _.filter(participantSelections, s => (_.indexOf(groupsToCreate, s.selection.group.name) > -1))) .then(participantSelections => participantSelections.map(sel => ({ participantId: sel.participantId, From 11138961e9f9958db02958251847e2316e7bcbd4 Mon Sep 17 00:00:00 2001 From: ritvje Date: Sun, 17 Jul 2016 12:05:03 +0300 Subject: [PATCH 4/4] Make sure selection is also defined --- src/kuksa-integration/rebuild-tables.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kuksa-integration/rebuild-tables.js b/src/kuksa-integration/rebuild-tables.js index 7caae9e0..be609a34 100644 --- a/src/kuksa-integration/rebuild-tables.js +++ b/src/kuksa-integration/rebuild-tables.js @@ -195,7 +195,7 @@ function buildSelectionTable() { .then(participants => Promise.each(participants, p => findKuksaParticipantExtraSelections({ where: { participantId: p.participantId }, include: { selection: 'group' } }) .then(participantSelections => participantSelections.map(selections => selections.toObject())) - .then(participantSelections => _.filter(participantSelections, s => !!s.selection.group)) // Apparently some selections don't have a group, so handle only selections with group + .then(participantSelections => _.filter(participantSelections, s => !!(s.selection && s.selection.group))) // Apparently some selections don't have a group, so handle only selections with group .then(participantSelections => _.filter(participantSelections, s => (_.indexOf(groupsToCreate, s.selection.group.name) > -1))) .then(participantSelections => participantSelections.map(sel => ({ participantId: sel.participantId,