github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/mirage/factories/deployment-task-group-summary.js (about) 1 import { Factory, faker } from 'ember-cli-mirage'; 2 3 const REF_TIME = new Date(); 4 5 export default Factory.extend({ 6 name: '', 7 8 autoRevert: () => Math.random() > 0.5, 9 promoted: () => Math.random() > 0.5, 10 11 requiresPromotion: false, 12 13 requireProgressBy: () => faker.date.past(0.5 / 365, REF_TIME), 14 15 desiredTotal: faker.random.number({ min: 1, max: 10 }), 16 17 desiredCanaries() { 18 return faker.random.number(Math.floor(this.desiredTotal / 2)); 19 }, 20 21 // PlacedCanaries is an array of allocation IDs. Since the IDs aren't currently 22 // used for associating allocations, any random value will do for now. 23 placedCanaries() { 24 return Array(faker.random.number(this.desiredCanaries)) 25 .fill(null) 26 .map(() => faker.random.uuid()); 27 }, 28 29 placedAllocs() { 30 return faker.random.number(this.desiredTotal); 31 }, 32 33 healthyAllocs() { 34 return faker.random.number(this.placedAllocs); 35 }, 36 37 unhealthyAllocs() { 38 return this.placedAllocs - this.healthyAllocs; 39 }, 40 });