click.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package model
  2. //web+h5+outside+ios+android
  3. const (
  4. TypeForWeb = "web"
  5. TypeForH5 = "h5"
  6. TypeForOutside = "outside"
  7. TypeForIOS = "ios"
  8. TypeForAndroid = "android"
  9. TypeForAndroidTv = "android_tv"
  10. PlatForWeb = int8(0)
  11. PlatForH5 = int8(1)
  12. PlatForOuter = int8(2)
  13. PlatForIos = int8(3)
  14. PlatForAndroid = int8(4)
  15. PlatForAndroidTV = int8(5)
  16. PlatForAutoPlayIOS = int8(6)
  17. PlafForAutoPlayInlineIOS = int8(7)
  18. PlatForAutoPlayAndroid = int8(8)
  19. PlatForAutoPlayInlineAndroid = int8(9)
  20. _maxDBTimes = 6
  21. )
  22. // ClickInfo is
  23. type ClickInfo struct {
  24. Aid int64
  25. Web int64
  26. H5 int64
  27. Outer int64
  28. Ios int64
  29. Android int64
  30. AndroidTV int64
  31. Sum int64
  32. DBTimes int
  33. LastChangeTime int64
  34. }
  35. // NeedRelease is
  36. func (c *ClickInfo) NeedRelease() bool {
  37. if c.DBTimes > _maxDBTimes {
  38. return true
  39. }
  40. return false
  41. }
  42. // ArcDuration is
  43. type ArcDuration struct {
  44. Duration int64
  45. GotTime int64
  46. }
  47. // Ready is
  48. func (c *ClickInfo) Ready(ts int64) {
  49. c.Sum = c.Sum + c.GetSum()
  50. c.LastChangeTime = ts
  51. c.Web, c.H5, c.Outer, c.Ios, c.Android, c.AndroidTV = 0, 0, 0, 0, 0, 0
  52. c.DBTimes++
  53. }
  54. // GetSum is
  55. func (c *ClickInfo) GetSum() (sum int64) {
  56. sum = c.Web + c.H5 + c.Outer + c.Ios + c.Android + c.AndroidTV
  57. return
  58. }