From d4ab8d962822a318b6c117a5ed4626dfd0606262 Mon Sep 17 00:00:00 2001 From: Ville Vuorenmaa Date: Wed, 20 Jul 2016 10:49:53 +0300 Subject: [PATCH 1/6] Fix date search test to really test query with other filter --- test/date-search.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/date-search.test.js b/test/date-search.test.js index 7e10f0d7..b00f2880 100644 --- a/test/date-search.test.js +++ b/test/date-search.test.js @@ -34,7 +34,7 @@ describe('Date search', () => { 'campGroup': 'Leirilippukunta', 'village': 'Kylä', 'subCamp': 'Alaleiri2', - 'ageGroup': 'sudenpentu', + 'ageGroup': 'seikkailija', 'memberNumber': 345, }, { @@ -104,7 +104,7 @@ describe('Date search', () => { it('Query with other filter', () => queryParticipants({ 'ageGroup':'sudenpentu' }, accessToken) .then(res => { - expectParticipants([ 'Tero', 'Teemu' ], res.body); + expectParticipants([ 'Teemu' ], res.body); }) ); @@ -116,14 +116,14 @@ describe('Date search', () => { ); it('Query with one date', () => - queryParticipants({ 'dates': ['2016-07-23T00:00:00.000Z'] }, accessToken) + queryParticipants({ 'dates': ['2016-07-22T00:00:00.000Z'] }, accessToken) .then(res => { expectParticipants([ 'Tero', 'Teemu' ], res.body); }) ); it('Query with one date and other filter', () => - queryParticipants({ 'and': [ { 'dates': ['2016-07-23T00:00:00.000Z'] }, { 'subCamp': 'Alaleiri2' } ] }, accessToken) + queryParticipants({ 'and': [ { 'dates': ['2016-07-23T00:00:00.000Z'] }, { 'ageGroup': 'seikkailija' } ] }, accessToken) .then(res => { expectParticipants([ 'Tero' ], res.body); }) From c4fcc08c0008d6504737d78d2c25761aa64adcaf Mon Sep 17 00:00:00 2001 From: Ville Vuorenmaa Date: Wed, 20 Jul 2016 10:57:03 +0300 Subject: [PATCH 2/6] Fix date filter constructing when query with other filters --- src/common/models/participant.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/models/participant.js b/src/common/models/participant.js index 783c984c..bf2d29f2 100644 --- a/src/common/models/participant.js +++ b/src/common/models/participant.js @@ -35,7 +35,7 @@ export default function (Participant) { if (where.and) { dates = where.and.filter(filter => filter.dates); - dates = dates.dates; + dates = dates[0].dates; where.and = where.and.filter(filter => !filter.dates); } else { dates = where.dates; From 31f9657604ab1fee170f41384c6c74b541dcfb1a Mon Sep 17 00:00:00 2001 From: Ville Vuorenmaa Date: Wed, 20 Jul 2016 11:14:07 +0300 Subject: [PATCH 3/6] Fix to work with text search --- src/common/models/participant.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/models/participant.js b/src/common/models/participant.js index bf2d29f2..b0dd5d8b 100644 --- a/src/common/models/participant.js +++ b/src/common/models/participant.js @@ -35,8 +35,10 @@ export default function (Participant) { if (where.and) { dates = where.and.filter(filter => filter.dates); - dates = dates[0].dates; - where.and = where.and.filter(filter => !filter.dates); + if (!_.isEmpty(dates)) { + dates = dates[0].dates; + where.and = where.and.filter(filter => !filter.dates); + } } else { dates = where.dates; } From 20d3402841754ef67257839c6c5d779e9dcd6826 Mon Sep 17 00:00:00 2001 From: Ville Vuorenmaa Date: Wed, 20 Jul 2016 11:18:08 +0300 Subject: [PATCH 4/6] Attempt to fix Kuksa payment-date mapping --- conf/payment-date-mappings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/payment-date-mappings.json b/conf/payment-date-mappings.json index 188a6d3b..bb40a02a 100644 --- a/conf/payment-date-mappings.json +++ b/conf/payment-date-mappings.json @@ -43,6 +43,6 @@ "su 31.7.": ["2016-07-31"], "Osallistun koko leirin ajaksi": ["2016-07-20","2016-07-21","2016-07-22","2016-07-23","2016-07-24","2016-07-25","2016-07-26","2016-07-27"], - "Osallistun koko purkuleirille (4 päivää) ja saan alennusta leirimaksusta 20 euroa. Alennuksen saa käteisellä purkuleiriltä poistuttaessa.": ["2016-07-28","2016-07-29","2016-07-30","2016-07-31"], + "Osallistun koko purkuleirille (4 päivää) ja saan alennusta leirimaksusta 20 euroa. Summa hyvitetään purkuleirin jälkeen..": ["2016-07-28","2016-07-29","2016-07-30","2016-07-31"], "Osallistun vain rakennus-/purkuleirille tai Home Hospitalityn isäntäperheenä.": [] } From ba6050b71e25f697685964116c7e504fb9f4c996 Mon Sep 17 00:00:00 2001 From: Ville Vuorenmaa Date: Wed, 20 Jul 2016 12:10:07 +0300 Subject: [PATCH 5/6] Check filter exists --- src/common/models/participant.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/models/participant.js b/src/common/models/participant.js index b0dd5d8b..235d2708 100644 --- a/src/common/models/participant.js +++ b/src/common/models/participant.js @@ -35,7 +35,7 @@ export default function (Participant) { if (where.and) { dates = where.and.filter(filter => filter.dates); - if (!_.isEmpty(dates)) { + if (dates && !_.isEmpty(dates)) { dates = dates[0].dates; where.and = where.and.filter(filter => !filter.dates); } From 318cf615b25fc369708f04ad97991264b5e3b490 Mon Sep 17 00:00:00 2001 From: Ville Vuorenmaa Date: Wed, 20 Jul 2016 13:49:37 +0300 Subject: [PATCH 6/6] Removed 2nd condition from familycamp mapping Only accommodation matters --- src/kuksa-integration/rebuild-tables.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/kuksa-integration/rebuild-tables.js b/src/kuksa-integration/rebuild-tables.js index a549f74b..fba8ab4d 100644 --- a/src/kuksa-integration/rebuild-tables.js +++ b/src/kuksa-integration/rebuild-tables.js @@ -69,8 +69,6 @@ function rebuildParticipantsTable() { function getSubCamp(participant) { 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'; }