kpi_func.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package service
  2. // 根据投准率计算投准系数
  3. func (s *Service) voteRightRatio(vr float64) (vf float64) {
  4. switch {
  5. case vr >= 0.9:
  6. vf = float64(1.2)
  7. case vr >= 0.8 && vr < 0.9:
  8. vf = float64(1.1)
  9. case vr >= 0.7 && vr < 0.8:
  10. vf = float64(0.9)
  11. case vr >= 0.6 && vr < 0.7:
  12. vf = float64(0.6)
  13. case vr >= 0.5 && vr < 0.6:
  14. vf = float64(0.3)
  15. case vr >= 0.4 && vr < 0.5:
  16. vf = float64(0.1)
  17. default:
  18. vf = float64(0)
  19. }
  20. return
  21. }
  22. // 根据活跃天数计算活跃系数
  23. func (s *Service) activeDaysRatio(activeDays int64) (af float64) {
  24. switch {
  25. case activeDays >= 26:
  26. af = float64(1.3)
  27. case activeDays >= 21 && activeDays <= 25:
  28. af = float64(1.2)
  29. case activeDays >= 16 && activeDays <= 20:
  30. af = float64(1.1)
  31. case activeDays >= 11 && activeDays <= 15:
  32. af = float64(1.0)
  33. case activeDays >= 6 && activeDays <= 10:
  34. af = float64(0.9)
  35. case activeDays >= 1 && activeDays <= 5:
  36. af = float64(0.7)
  37. default:
  38. af = float64(0)
  39. }
  40. return
  41. }
  42. // 根据观点数量计算观点数量系数
  43. func (s *Service) opinionNumsRatio(opinionNums int64) (of float64) {
  44. switch {
  45. case opinionNums >= 31:
  46. of = 1.3
  47. case opinionNums >= 16 && opinionNums <= 30:
  48. of = 1.2
  49. case opinionNums >= 6 && opinionNums <= 15:
  50. of = 1.1
  51. case opinionNums >= 1 && opinionNums <= 5:
  52. of = 1
  53. default:
  54. of = 0.8
  55. }
  56. return
  57. }
  58. // 根据观点(赞-踩)数计算观点质量系数
  59. func (s *Service) opinionQualityRatio(opinionQuality int64) (oqf float64) {
  60. switch {
  61. case opinionQuality >= 16:
  62. oqf = 1.3
  63. case opinionQuality >= 6 && opinionQuality <= 15:
  64. oqf = 1.2
  65. case opinionQuality >= 1 && opinionQuality <= 5:
  66. oqf = 1.1
  67. case opinionQuality == 0:
  68. oqf = 1
  69. case opinionQuality >= -10 && opinionQuality <= -1:
  70. oqf = 0.8
  71. case opinionQuality >= -20 && opinionQuality <= -11:
  72. oqf = 0.7
  73. case opinionQuality <= -21:
  74. oqf = 0.5
  75. }
  76. return
  77. }