src/App/Entity/ExternalPartner/ExternalPartnerEventAggregation.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ExternalPartner;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity
  7. *
  8. * @ORM\Table(
  9. * name="external_partner_event_aggregations"
  10. * )
  11. */
  12. class ExternalPartnerEventAggregation
  13. {
  14. public const RESOLUTION_DAILY = 1;
  15. public const RESOLUTION_WEEKLY = 2;
  16. public const RESOLUTION_MONTHLY = 3;
  17. public const RESOLUTION_ALLTIME = 4;
  18. public const AGGREGATION_TYPE_RECURRENT_JOB_CREATED = 0;
  19. public const AGGREGATION_TYPE_RECURRENT_JOB_UPDATED = 1;
  20. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL = 2;
  21. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_REGISTERED = 3;
  22. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_UNREGISTERED = 4;
  23. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_WITH_CV = 5;
  24. public const AGGREGATION_TYPE_JOBRADAR_CREATED = 6;
  25. public const AGGREGATION_TYPE_PREMIUM_JOBRADAR_CREATED = 7;
  26. public const AGGREGATION_TYPE_RECURRENT_JOB_SHARE_PAGE_REQUESTED = 8;
  27. public const AGGREGATION_TYPE_USER_CREATED = 9;
  28. public const AGGREGATION_TYPE_RECURRENT_JOB_HAS_BEEN_PROLONGED = 10;
  29. public const AGGREGATION_TYPE_RECURRENT_JOB_HAS_BEEN_REACTIVATED_BECAUSE_QUOTA_BECAME_AVAILABLE_AGAIN = 11;
  30. public const AGGREGATION_TYPE_RECURRENT_JOB_HAS_BEEN_DEACTIVATED = 12;
  31. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED = 13;
  32. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_CONTENT_DISTRIBUTION_PARTNER = 14;
  33. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_JOBLIFT = 15;
  34. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_TALENTCOM = 16;
  35. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_JOBRAPIDO = 17;
  36. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_INDEED = 18;
  37. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_EBAY = 19;
  38. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_KIMETA = 20;
  39. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_STELLENONLINE = 21;
  40. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_GOOGLE_FOR_JOBS = 22;
  41. public const AGGREGATION_TYPE_RECURRENT_JOB_HAS_BEEN_REACTIVATED_BECAUSE_RECURRENT_JOBS_LIMIT_HAS_CAPACITY_AGAIN = 23;
  42. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_AGENTUR_FUER_ARBEIT = 24;
  43. public const AGGREGRATION_TYPE_FORWARDED_ON_PLATFORM_SITE_JOBOO = 25;
  44. public const AGGREGRATION_TYPE_FORWARDED_ON_PLATFORM_SITE_JOBOO_ONLINE = 26;
  45. public const AGGREGRATION_TYPE_FORWARDED_ON_PLATFORM_SITE_RECRUIT_DL = 27;
  46. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_CONTENT_DISTRIBUTION_PARTNER = 28;
  47. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_JOBLIFT = 29;
  48. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_TALENTCOM = 30;
  49. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_JOBRAPIDO = 31;
  50. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_INDEED = 32;
  51. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_EBAY = 33;
  52. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_KIMETA = 34;
  53. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_STELLENONLINE = 35;
  54. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_GOOGLE_FOR_JOBS = 36;
  55. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_AGENTUR_FUER_ARBEIT = 37;
  56. public const AGGREGRATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_ON_PLATFORM_SITE_JOBOO = 38;
  57. public const AGGREGRATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_ON_PLATFORM_SITE_JOBOO_ONLINE = 39;
  58. public const AGGREGRATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_ON_PLATFORM_SITE_RECRUIT_DL = 40;
  59. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_FACEBOOK = 41;
  60. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_GOOGLE_ADS = 42;
  61. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_FACEBOOK = 43;
  62. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_GOOGLE_ADS = 44;
  63. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_MEINESTADT = 45;
  64. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_MEINESTADT = 46;
  65. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_JOBIJOBA = 47;
  66. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_JOBIJOBA = 48;
  67. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_WHATJOBS = 49;
  68. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_WHATJOBS = 50;
  69. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_JOOBLE = 51;
  70. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_JOOBLE = 52;
  71. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_CRITEO = 53;
  72. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_CRITEO = 54;
  73. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_PERSPECTIVE = 55;
  74. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_STEPSTONE = 56;
  75. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_STEPSTONE = 57;
  76. public const AGGREGATION_TYPE_EXTENDED_APPLICATION_HAS_BEEN_CREATED_VIA_PERSOMATCH = 58;
  77. public const AGGREGATION_TYPE_FORWARDED_TO_EXTERNAL_PARTNER_URL_VIA_PERSOMATCH = 59;
  78. /**
  79. * (Note that we use CET and CEST interchangeably here, because we mean the time in Germany, regardless of whether
  80. * it's winter or summer time.).
  81. *
  82. * We normally store all timestamps in our DB tables as UTC date-times only. However, this is not possible here.
  83. * The reason is that we need to report the aggregated values for a timezone. Because the
  84. * "resolution starting at" info is not a discrete point in time which can later be recalculated
  85. * safely to the corresponding point in time in any other timezone, we would end up with wrong data.
  86. * Instead, the timestamp refers to the first timestamp of a whole day, week, or month.
  87. *
  88. * Sadly, we cannot store both timestamps together.
  89. *
  90. * Here's why: It's 22:59 o'clock in UTC and 23:59 o'clock in CET on January 1, 2021.
  91. *
  92. * The timestamps are thus: 2021-01-01 22:59:00 in UTC and 2021-01-01 23:59:00 in CET.
  93. *
  94. * A row is inserted or updated that says that the $numberOfOccurrences for $aggregationType X on that day is 10,
  95. * like this:
  96. *
  97. * resolution=day
  98. * aggregationType=X
  99. * resolutionStartingAtUtc=2021-01-01 00:00:00
  100. * resolutionStartingAtCet=2021-01-01 00:00:00
  101. * numberOfOccurrences=10
  102. *
  103. * Here is what would happen 3 minutes later:
  104. *
  105. * It's now 23:02 o'clock on January 1, 2021 in UTC, but 00:02 o'clock in CET on January 2(!), 2021.
  106. *
  107. * The $numberOfOccurrences for UTC would need to be increased from 10 to 11, because the event occured while it
  108. * was still January 1 in UTC.
  109. *
  110. * But if we would update the above row accordingly, like this:
  111. *
  112. * resolution=day
  113. * aggregationType=X
  114. * resolutionStartingAtUtc=2021-01-01 00:00:00
  115. * resolutionStartingAtCet=2021-01-01 00:00:00
  116. * numberOfOccurrences=11
  117. *
  118. * then the information is now correct for UTC, but incorrect for CET, because the 11th occurrence happened
  119. * while it was already January 2 in CET.
  120. *
  121. * Thus, it would be correct to persist that
  122. * the numberOfOccurrences=10 where resolutionStartingAtCet=2021-01-01 00:00:00,
  123. * and numberOfOccurrences=1 where resolutionStartingAtCet=2021-01-02 00:00:00.
  124. *
  125. * If we have the UTC and CET timestamp together in one row, it is not possible to persist the data correctly.
  126. *
  127. * We therefore aggregate twice, with one row where the date-time is from UTC and one from CET.
  128. */
  129. /**
  130. * @ORM\Column(name="timezone", type="smallint", nullable=false)
  131. *
  132. * @ORM\Id
  133. */
  134. private int $timezone;
  135. /**
  136. * @ORM\Column(name="resolution", type="smallint", nullable=false)
  137. *
  138. * @ORM\Id
  139. */
  140. private int $resolution;
  141. /**
  142. * @ORM\Column(name="aggregation_type", type="smallint", nullable=false)
  143. *
  144. * @ORM\Id
  145. */
  146. private int $aggregationType;
  147. /**
  148. * @ORM\Column(name="resolution_starting_at", type="datetime", nullable=false)
  149. *
  150. * @ORM\Id
  151. */
  152. private DateTime $resolutionStartingAt;
  153. /**
  154. * @ORM\Column(name="integrated_external_partner_customer_id", type="guid", nullable=false)
  155. *
  156. * @ORM\Id
  157. */
  158. protected string $integratedExternalPartnerCustomerId;
  159. /**
  160. * @ORM\Column(name="number_of_occurrences", type="integer", nullable=false)
  161. */
  162. private int $numberOfOccurrences;
  163. }