tRbacUserModel.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. 'use strict';
  2. module.exports = app => {
  3. const mongoose = app.mongoose;
  4. const Schema = mongoose.Schema;
  5. const conn = app.mongooseDB.get('etlLocalDB');
  6. // 用户信息 本地清洗 数据结构
  7. const TRbacUserSchema = new Schema({
  8. create_date: { type: Number }, // 统计的数据是哪一天的
  9. year: { type: Number }, // 年 统计的数据
  10. month: { type: Number }, // 月 统计的数据
  11. day: { type: Number }, // 日 统计的数据
  12. dateString: { type: String }, // 时间字符串 yyyy-MM-dd
  13. start_time: { type: Date }, // 开始统计时间
  14. end_time: { type: Date, default: Date.now }, // 结束统计时间
  15. total: { type: Number }, // 用户总数
  16. newTotal: { type: Number }, // 用户增量
  17. sexAndAgeTotal: [// 性别和年龄统计
  18. {
  19. _id: { type: String }, // 分段
  20. fCount: { type: Number }, // 男数量
  21. mCount: { type: Number }, // 女数量
  22. count: { type: Number }, // 总数
  23. },
  24. ],
  25. appTotal: { type: Number }, // app用户总数
  26. appSexAndAgeTotal: [// app性别和年龄统计
  27. {
  28. _id: { type: String }, // 分段
  29. fCount: { type: Number }, // 男数量
  30. mCount: { type: Number }, // 女数量
  31. count: { type: Number }, // 总数
  32. },
  33. ],
  34. newAppTotal: { type: Number }, // app新增用户总数
  35. newAppSexAndAgeTotal: [// app新增性别和年龄统计
  36. {
  37. _id: { type: String }, // 分段
  38. fCount: { type: Number }, // 男数量
  39. mCount: { type: Number }, // 女数量
  40. count: { type: Number }, // 总数
  41. },
  42. ],
  43. activeAppTotal: { type: Number }, // app 日活跃用户总数
  44. activeAppMonth: { type: Number }, // app 月活跃用户总数
  45. activeAppYear: { type: Number }, // app 年活跃用户总数
  46. activeAppSexAndAgeTotal: [// app活跃性别和年龄统计
  47. {
  48. _id: { type: String }, // 分段
  49. fCount: { type: Number }, // 男数量
  50. mCount: { type: Number }, // 女数量
  51. count: { type: Number }, // 总数
  52. },
  53. ],
  54. iviTotal: { type: Number }, // ivi用户总数
  55. iviSexAndAgeTotal: [// ivi性别和年龄统计
  56. {
  57. _id: { type: String }, // 分段
  58. fCount: { type: Number }, // 男数量
  59. mCount: { type: Number }, // 女数量
  60. count: { type: Number }, // 总数
  61. },
  62. ],
  63. newIviTotal: { type: Number }, // ivi新增用户总数
  64. newIviSexAndAgeTotal: [// ivi新增性别和年龄统计
  65. {
  66. _id: { type: String }, // 分段
  67. fCount: { type: Number }, // 男数量
  68. mCount: { type: Number }, // 女数量
  69. count: { type: Number }, // 总数
  70. },
  71. ],
  72. activeIviTotal: { type: Number }, // ivi 日活跃用户总数
  73. activeIviMonth: { type: Number }, // ivi 月活跃用户总数
  74. activeIviYear: { type: Number }, // ivi 年活跃用户总数
  75. activeIviSexAndAgeTotal: [// ivi活跃性别和年龄统计
  76. {
  77. _id: { type: String }, // 分段
  78. fCount: { type: Number }, // 男数量
  79. mCount: { type: Number }, // 女数量
  80. count: { type: Number }, // 总数
  81. },
  82. ],
  83. saledTotal: { type: Number }, // 实销,
  84. saledAppTotal: { type: Number }, // app实销,
  85. saledIviTotal: { type: Number }, // ivi实销,
  86. });
  87. TRbacUserSchema.index({ create_date: -1 });
  88. return conn.model('TRbacUser', TRbacUserSchema, 'lc_t_rbac_user');
  89. };