Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/date filter #158

Merged
merged 3 commits into from
Jul 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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