Skip to content

Commit

Permalink
Merge pull request #158 from partio-scout/bugfix/date-filter
Browse files Browse the repository at this point in the history
Bugfix/date filter
  • Loading branch information
googol authored Jul 21, 2016
2 parents f0032e2 + 8195dcd commit 4f3275a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 8 additions & 0 deletions scripts/create-fake-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import faker from 'faker';
const ParticipantModel = app.models.Participant;
const createParticipant = Promise.promisify(ParticipantModel.create, { context: ParticipantModel });

const ParticipantDateModel = app.models.ParticipantDate;
const createParticipantDate = Promise.promisify(ParticipantDateModel.create, { context: ParticipantDateModel });

const opts = require('commander')
.usage('<amount of fake participants to create>')
.parse(process.argv);
Expand Down Expand Up @@ -214,6 +217,7 @@ function createMockParticipants(i) {
countParticipants();
} else {
createParticipant(generateRandomParticipant(i))
.tap(addParticipantDate)
.then(createdParticipantInfo => {
createMockParticipants(i-1);
})
Expand All @@ -223,5 +227,9 @@ function createMockParticipants(i) {
}
}

function addParticipantDate(participant) {
return createParticipantDate({ participantId: participant.participantId, date: new Date(2016,6,22) });
}

console.log(`Attempting to create ${amountToCreate} mock participants.`);
createMockParticipants(amountToCreate);
6 changes: 1 addition & 5 deletions src/common/models/participant.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ export default function (Participant) {
}

function constructInternalDateFilter(participantIds) {
const or = [];
participantIds.map( id => {
or.push({ participantId: id });
});
return { or: or };
return { participantId: { inq: participantIds } };
}
}

Expand Down

0 comments on commit 4f3275a

Please sign in to comment.