BigData.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. Ext.define('uas.data.BigData', {
  2. requires: [
  3. 'uas.data.Init'
  4. ]
  5. }, function() {
  6. function process(data) {
  7. for (var i = 0; i < data.length; ++i) {
  8. var d = data[i];
  9. d.ratingLastYear = Math.max(Math.round(d.rating[0] / 2), 1);
  10. d.ratingThisYear = Math.max(Math.round(d.rating[d.rating.length - 1] / 2), 1);
  11. }
  12. return data;
  13. }
  14. Ext.ux.ajax.SimManager.register({
  15. '/uas/BigData': {
  16. type: 'json',
  17. data: process((function() {
  18. let arr = [];
  19. const foreNames = ["Nige","Jamie","Jay","Nicolas","Tommy","David","Ed","Dave","Abe","Adam","Aaron"];
  20. const surNames = ["Mishcon","White","Davis","Kaneda","Spencer","Avins","Robinson","Elias","Conran","Ferrero","Maintz"];
  21. const departments = ["Accounting","Administration","Engineering","Managment","Marketing","QA","Sales","Support"];
  22. for(let i = 0; i < 30000; i++) {
  23. let forename = foreNames[Math.round(Math.random()*(foreNames.length - 1))];
  24. let surname = surNames[Math.round(Math.random()*(surNames.length - 1))];
  25. let dob = Ext.Date.add(new Date('1960-01-01'), 'd', Math.round(Math.random()*40 + 1)*365);
  26. let department = departments[Math.round(Math.random()*(departments.length - 1))];
  27. let obj = {
  28. employeeNo: Math.round(Math.random()*999999),
  29. rating: [Math.round(Math.random()*9), Math.round(Math.random()*9), Math.round(Math.random()*9), Math.round(Math.random()*9), Math.round(Math.random()*9),
  30. Math.round(Math.random()*9), Math.round(Math.random()*9), Math.round(Math.random()*9), Math.round(Math.random()*9), Math.round(Math.random()*9),
  31. ],
  32. salary: Math.round(Math.random()*8 + 1) * Math.pow(10, Math.round(Math.random()*3 + 2) ),
  33. forename: forename,
  34. surname: surname,
  35. email: forename.toLowerCase() + '.' + surname.toLowerCase() + '@sentcha.com',
  36. department: department,
  37. dob: Ext.util.Format.date(dob, 'Ymd'),
  38. joinDate: Ext.util.Format.date(Ext.Date.add(dob, Math.round(Math.random()*15 + 15)) * 365, 'Ymd'),
  39. sickDays: Math.round(Math.random()*10),
  40. holidayDays: Math.round(Math.random()*10),
  41. holidayAllowance: Math.round(Math.random()*20 + 20),
  42. noticePeriod: Math.round(Math.random()*2 + 1) + ['month', 'weeks'][Math.round(Math.random()*1)],
  43. avatar: "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcSdj-gG2gXPkOUJGQ2r-3A5AnIgASv19axozeYMWssSVJyySvBIeQ",
  44. verified: Math.round(Math.random()) === 1
  45. };
  46. arr.push(obj);
  47. }
  48. return arr;
  49. })())
  50. }
  51. });
  52. });