src/App/Entity/StatisticsAggregationCache.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Utility\DateTimeUtility;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use function json_encode;
  7. /**
  8. * @ORM\Entity()
  9. *
  10. * @ORM\Table(
  11. * name="statistics_aggregation_caches",
  12. * )
  13. */
  14. class StatisticsAggregationCache
  15. {
  16. /**
  17. * @var string
  18. *
  19. * @ORM\Column(name="id", type="string", length=32)
  20. *
  21. * @ORM\Id
  22. */
  23. protected $id;
  24. public function setId(string $id): void
  25. {
  26. $this->id = $id;
  27. }
  28. public function getId()
  29. {
  30. return $this->id;
  31. }
  32. /**
  33. * @var string
  34. *
  35. * @ORM\Column(name="value", type="text", nullable=false)
  36. */
  37. protected $value;
  38. public function setValue(string $value): void
  39. {
  40. $this->value = $value;
  41. }
  42. public function getValue(): string
  43. {
  44. return $this->value;
  45. }
  46. public static function calculateKey(string $class, DateTime $dateTime, string $filterByAffectedUserIs, array $eventTypes, string $other): string
  47. {
  48. return md5($class . $dateTime->format('Y-m-d') . $filterByAffectedUserIs . json_encode($eventTypes) . $other);
  49. }
  50. public static function getMinimumDateTimeForCache(): DateTime
  51. {
  52. return DateTimeUtility::createDateTimeUtc('-1 week');
  53. }
  54. }