src/App/Entity/SearchtermEnteredEvent.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Utility\GuidUtility;
  4. use App\Utility\ReflectionHelper;
  5. use DateTime;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Exception;
  8. /**
  9. * @ORM\Entity
  10. *
  11. * @ORM\Table(
  12. * name="searchterm_entered_events",
  13. * indexes={
  14. *
  15. * @ORM\Index(name="occured_at_idx", columns={"occured_at"})
  16. * }
  17. * )
  18. */
  19. class SearchtermEnteredEvent
  20. {
  21. public const CONTEXT_JOBSEEKER_REGISTRATION = 0;
  22. public const CONTEXT_JOBOFFERER_REGISTRATION = 1;
  23. public const CONTEXT_WANTED_JOB_CREATION = 2;
  24. public const CONTEXT_RECURRENT_JOB_CREATION = 3;
  25. public const CONTEXT_WANTED_JOBS_SEARCH_LOGGED_IN = 4;
  26. public const CONTEXT_WANTED_JOBS_SEARCH_ANONYMOUS = 5;
  27. public const CONTEXT_RECURRENT_JOBS_SEARCH_LOGGED_IN = 6;
  28. public const CONTEXT_RECURRENT_JOBS_SEARCH_ANONYMOUS = 7;
  29. /**
  30. * @throws Exception
  31. */
  32. public function __construct(
  33. DateTime $occuredAt,
  34. string $searchterm,
  35. int $context
  36. ) {
  37. $this->occuredAt = $occuredAt;
  38. $this->searchterm = $searchterm;
  39. if (!ReflectionHelper::hasConstWithValue(self::class, 'CONTEXT_', $context)) {
  40. throw new Exception('Value ' . $context . ' not allowed for $context.');
  41. }
  42. $this->context = $context;
  43. }
  44. /**
  45. * @ORM\GeneratedValue(strategy="CUSTOM")
  46. *
  47. * @ORM\CustomIdGenerator(class="App\Utility\DatabaseIdGenerator")
  48. *
  49. * @ORM\Column(name="id", type="guid")
  50. *
  51. * @ORM\Id
  52. */
  53. private ?string $id;
  54. public function setId(string $id): void
  55. {
  56. GuidUtility::validOrThrow($id);
  57. $this->id = $id;
  58. }
  59. public function getId(): ?string
  60. {
  61. return $this->id;
  62. }
  63. /**
  64. * @ORM\Column(name="occured_at", type="datetime", nullable=false)
  65. */
  66. private DateTime $occuredAt;
  67. public function getOccuredAt(): DateTime
  68. {
  69. return $this->occuredAt;
  70. }
  71. /**
  72. * @ORM\Column(name="searchterm", type="string", nullable=false)
  73. */
  74. private string $searchterm;
  75. public function getSearchterm(): string
  76. {
  77. return $this->searchterm;
  78. }
  79. /**
  80. * @var array|string[]|null
  81. *
  82. * @ORM\Column(name="additional_searchterms", type="array", nullable=true)
  83. */
  84. private ?array $additionalSearchterms = null;
  85. public function setAdditionalSearchterms(?array $additionalSearchterms = null): void
  86. {
  87. $this->additionalSearchterms = $additionalSearchterms;
  88. }
  89. /**
  90. * @return array|string[]|null
  91. */
  92. public function getAdditionalSearchterms(): ?array
  93. {
  94. return $this->additionalSearchterms;
  95. }
  96. /**
  97. * @ORM\Column(name="context", type="integer", nullable=false)
  98. */
  99. private int $context;
  100. public function getContext(): int
  101. {
  102. return $this->context;
  103. }
  104. /**
  105. * @ORM\Column(name="number_of_occupational_fields", type="integer", nullable=true)
  106. */
  107. private ?int $numberOfOccupationalFields = null;
  108. public function setNumberOfOccupationalFields(?int $numberOfOccupationalFields = null): void
  109. {
  110. $this->numberOfOccupationalFields = $numberOfOccupationalFields;
  111. }
  112. public function getNumberOfOccupationalFields(): ?int
  113. {
  114. return $this->numberOfOccupationalFields;
  115. }
  116. /**
  117. * @ORM\Column(name="number_of_relevant_occupational_fields", type="integer", nullable=true)
  118. */
  119. private ?int $numberOfRelevantOccupationalFields = null;
  120. public function setNumberOfRelevantOccupationalFields(?int $numberOfRelevantOccupationalFields = null): void
  121. {
  122. $this->numberOfRelevantOccupationalFields = $numberOfRelevantOccupationalFields;
  123. }
  124. public function getNumberOfRelevantOccupationalFields(): ?int
  125. {
  126. return $this->numberOfRelevantOccupationalFields;
  127. }
  128. /**
  129. * @ORM\Column(name="number_of_relevant_professions", type="integer", nullable=true)
  130. */
  131. private ?int $numberOfRelevantProfessions = null;
  132. public function setNumberOfRelevantProfessions(?int $numberOfRelevantProfessions = null): void
  133. {
  134. $this->numberOfRelevantProfessions = $numberOfRelevantProfessions;
  135. }
  136. public function getNumberOfRelevantProfessions(): ?int
  137. {
  138. return $this->numberOfRelevantProfessions;
  139. }
  140. /**
  141. * @ORM\Column(name="number_of_hits_in_search", type="integer", nullable=true)
  142. */
  143. private ?int $numberOfHitsInSearch = null;
  144. public function setNumberOfHitsInSearch(?int $numberOfHitsInSearch = null): void
  145. {
  146. $this->numberOfHitsInSearch = $numberOfHitsInSearch;
  147. }
  148. public function getNumberOfHitsInSearch(): ?int
  149. {
  150. return $this->numberOfHitsInSearch;
  151. }
  152. /**
  153. * @ORM\Column(name="number_of_hits_per_block", type="text", length=4096, nullable=true)
  154. */
  155. private ?string $numberOfHitsPerBlock = null;
  156. public function getNumberOfHitsPerBlock(): ?string
  157. {
  158. return $this->numberOfHitsPerBlock;
  159. }
  160. /** @throws Exception */
  161. public function setNumberOfHitsPerBlock(?string $numberOfHitsPerBlock): void
  162. {
  163. if (!is_null($numberOfHitsPerBlock)) {
  164. if (is_null(json_decode($numberOfHitsPerBlock))) {
  165. throw new Exception('additionalData must be valid JSON');
  166. }
  167. }
  168. $this->numberOfHitsPerBlock = $numberOfHitsPerBlock;
  169. }
  170. /**
  171. * @ORM\Column(name="affected_user_id", type="guid", nullable=true)
  172. *
  173. * We don't make this a foreign key on purpose, we don't need the integrity and don't want to delete event data
  174. * if a user is deleted.
  175. */
  176. private ?string $affectedUserId = null;
  177. public function setAffectedUserId(?string $userId = null): void
  178. {
  179. GuidUtility::validOrThrow($userId, true);
  180. $this->affectedUserId = $userId;
  181. }
  182. public function getAffectedUserId(): ?string
  183. {
  184. return $this->affectedUserId;
  185. }
  186. /**
  187. * @ORM\Column(name="affected_user_is_jobofferer", type="boolean", nullable=false)
  188. */
  189. private bool $affectedUserIsJobofferer = false;
  190. public function setAffectedUserIsJobofferer(bool $affectedUserIsJobofferer): void
  191. {
  192. $this->affectedUserIsJobofferer = $affectedUserIsJobofferer;
  193. }
  194. public function getAffectedUserIsJobofferer(): bool
  195. {
  196. return $this->affectedUserIsJobofferer;
  197. }
  198. /**
  199. * @ORM\Column(name="affected_user_is_jobseeker", type="boolean", nullable=false)
  200. */
  201. private bool $affectedUserIsJobseeker = false;
  202. public function setAffectedUserIsJobseeker(bool $affectedUserIsJobseeker): void
  203. {
  204. $this->affectedUserIsJobseeker = $affectedUserIsJobseeker;
  205. }
  206. public function getAffectedUserIsJobseeker(): bool
  207. {
  208. return $this->affectedUserIsJobseeker;
  209. }
  210. /**
  211. * @ORM\Column(name="affected_user_registered_at", type="datetime", nullable=true)
  212. *
  213. * In order to show statistics related to the cohorte of all users registered on day X, we need this field
  214. *
  215. * E.g. "from all user registered on 2018-04-07, how many ran into error X?"
  216. */
  217. private ?DateTime $affectedUserRegisteredAt = null;
  218. public function setAffectedUserRegisteredAt(?DateTime $affectedUserRegisteredAt = null): void
  219. {
  220. $this->affectedUserRegisteredAt = $affectedUserRegisteredAt;
  221. }
  222. public function getAffectedUserRegisteredAt(): ?DateTime
  223. {
  224. return $this->affectedUserRegisteredAt;
  225. }
  226. /**
  227. * @ORM\Column(name="admin_user_id", type="guid", nullable=true)
  228. *
  229. * We don't make this a foreign key on purpose, we don't need the integrity and don't want to delete event data
  230. * if a user is deleted.
  231. */
  232. private ?string $adminUserId = null;
  233. public function setAdminUserId(?string $adminUserId = null): void
  234. {
  235. GuidUtility::validOrThrow($adminUserId, true);
  236. $this->adminUserId = $adminUserId;
  237. }
  238. public function getAdminUserId(): ?string
  239. {
  240. return $this->adminUserId;
  241. }
  242. /**
  243. * @ORM\Column(name="request_id", type="text", length=256, nullable=true)
  244. */
  245. private ?string $requestId = null;
  246. public function setRequestId(?string $requestId = null): void
  247. {
  248. $this->requestId = $requestId;
  249. }
  250. public function getRequestId(): ?string
  251. {
  252. return $this->requestId;
  253. }
  254. /**
  255. * @ORM\Column(name="session_id", type="text", length=256, nullable=true)
  256. */
  257. private ?string $sessionId = null;
  258. public function setSessionId(?string $sessionId = null): void
  259. {
  260. $this->sessionId = $sessionId;
  261. }
  262. public function getSessionId(): ?string
  263. {
  264. return $this->sessionId;
  265. }
  266. /**
  267. * @ORM\Column(name="client_id", type="text", length=64, nullable=true)
  268. */
  269. private ?string $clientId = null;
  270. public function setClientId(?string $clientId = null): void
  271. {
  272. $this->clientId = $clientId;
  273. }
  274. public function getClientId(): ?string
  275. {
  276. return $this->clientId;
  277. }
  278. /**
  279. * @ORM\Column(name="is_probably_bot_request", type="boolean", nullable=true)
  280. */
  281. private ?bool $isProbablyBotRequest = null;
  282. public function setIsProbablyBotRequest(?bool $isProbablyBotRequest): void
  283. {
  284. $this->isProbablyBotRequest = $isProbablyBotRequest;
  285. }
  286. }