FlexitimeTracker/TestData/generate.js
chris.watts90@outlook.com b7492479c9 updated file to generate testcard data.
updated userstest endpoint to return the usercount parameter.
2017-01-29 15:25:47 +00:00

63 lines
1.8 KiB
JavaScript

module.exports = function(){
var fakeTimeDataCount = 4000, maxUserCount = 120, unassignedCardCount = 4;
var faker = require("faker");
var _ = require("lodash");
var directions = ["in", "out"];
var usersData = _.times(maxUserCount, function (n)
{
return {
id: n, //needed for the /users/id endpoint
Id: n,
UserId: n,
FirstName: faker.name.firstName(),
LastName: faker.name.lastName(),
HoursPerWeek: 37.0
}
}
);
var userSwipeDataPoints = _.times (fakeTimeDataCount, function(n)
{
return {
id: n,
Id: n,
UserId: faker.random.number(maxUserCount),
Timestamp: faker.date.past(),
Direction: directions[faker.random.number(1)]
}
}
);
//var userDataObject = {users: _.orderBy(usersData, ["lastName", "firstName"],["asc", "asc"])};
var unassignedTestCards = _.times(unassignedCardCount, function(n)
{
return {
id: n,
Id: n,
UserId: -1,
IsSelected: false, //needed for knockout checked binding.
CardUId: faker.random.uuid()
}
});
return {
timelogs: _.orderBy(userSwipeDataPoints, ["id"], ["asc"]),
//users: _.orderBy(data, ["userId", "asc"]),
users: _.orderBy(usersData, ["lastName", "firstName"],["asc", "asc"]),
//weather: _.orderBy(data, ["timestamp"],["asc"]),
stats: _.countBy(userSwipeDataPoints, "userId"),
timelogtest: {
Logs: _.orderBy(userSwipeDataPoints, "Timestamp", "asc")
},
userstest: {
UserCount: maxUserCount,
Users: _.orderBy(usersData, ["lastName", "firstName"],["asc", "asc"])
},
unassignedCards: { data: unassignedTestCards}
}
}
/*
so to get a list of the available users, call /users
to get specific user info, call /userSwipeData/<userId>
*/