src/Entity/TeamplayUserRecap.php line 62

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  7. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  8. use App\Repository\TeamplayUserRecapRepository;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * Snapshot des performances d'un utilisateur à la fin d'un Teamplay
  15.  * 
  16.  * @ORM\Entity(repositoryClass=TeamplayUserRecapRepository::class)
  17.  * @ORM\Table(
  18.  *     name="teamplay_user_recap",
  19.  *     uniqueConstraints={
  20.  *         @ORM\UniqueConstraint(name="unique_user_teamplay_recap", columns={"user_id", "teamplay_id"})
  21.  *     },
  22.  *     indexes={
  23.  *         @ORM\Index(name="idx_user_recap", columns={"user_id"}),
  24.  *         @ORM\Index(name="idx_teamplay_recap", columns={"teamplay_id"}),
  25.  *         @ORM\Index(name="idx_team_recap", columns={"team_id"}),
  26.  *         @ORM\Index(name="idx_recap_created", columns={"created_at"})
  27.  *     }
  28.  * )
  29.  * @ApiResource(
  30.  *      normalizationContext={"groups"={"teamplay_recap:read"}},
  31.  *      denormalizationContext={"groups"={"teamplay_recap:write"}},
  32.  *      itemOperations={
  33.  *          "get"={"security"="is_granted('ROLE_USER')"},
  34.  *          "delete"={"security"="is_granted('ROLE_ADMIN')"}
  35.  *      },
  36.  *      collectionOperations={
  37.  *          "get"={"security"="is_granted('ROLE_USER')"},
  38.  *          "post"={"security"="is_granted('ROLE_ADMIN')"},
  39.  *          "get_user_history"={
  40.  *              "method"="GET",
  41.  *              "path"="/users/{id}/teamplay-history",
  42.  *              "controller"="App\Controller\Api\TeamplayRecapController::getUserHistory",
  43.  *              "security"="is_granted('ROLE_USER')",
  44.  *              "read"=false,
  45.  *              "pagination_enabled"=true,
  46.  *              "defaults"={"_api_receive"=false}
  47.  *          }
  48.  *      }
  49.  * )
  50.  * @ApiFilter(SearchFilter::class, properties={
  51.  *   "user": "exact",
  52.  *    "teamplay": "exact", 
  53.  *   "team": "exact",
  54.  *    "company": "exact"
  55.  * })
  56.  * @ApiFilter(OrderFilter::class, properties={"id", "createdAt", "teamplayStartDate", "teamplayEndDate", "totalPoints", "userRank"})
  57.  * @ApiFilter(PropertyFilter::class, arguments={"parameterName"="fields", "overrideDefaultProperties"=true})
  58.  */
  59. class TeamplayUserRecap
  60. {
  61.     /**
  62.      * @ORM\Id
  63.      * @ORM\GeneratedValue
  64.      * @ORM\Column(type="integer")
  65.      * @Groups({"teamplay_recap:read"})
  66.      */
  67.     private $id;
  68.     // ═══════════════════════════════════════════════════════════════
  69.     // RELATIONS
  70.     // ═══════════════════════════════════════════════════════════════
  71.     /**
  72.      * @ORM\ManyToOne(targetEntity=User::class)
  73.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  74.      * @Assert\NotNull
  75.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  76.      */
  77.     private $user;
  78.     /**
  79.      * @ORM\ManyToOne(targetEntity=Teamplay::class)
  80.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  81.      * @Assert\NotNull
  82.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  83.      */
  84.     private $teamplay;
  85.     /**
  86.      * @ORM\ManyToOne(targetEntity=Team::class)
  87.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  88.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  89.      */
  90.     private $team;
  91.     /**
  92.      * @ORM\ManyToOne(targetEntity=Company::class)
  93.      * @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
  94.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  95.      */
  96.     private $company;
  97.     // ═══════════════════════════════════════════════════════════════
  98.     // INFORMATIONS TEAMPLAY (SNAPSHOT)
  99.     // ═══════════════════════════════════════════════════════════════
  100.     /**
  101.      * @ORM\Column(type="string", length=255)
  102.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  103.      */
  104.     private $teamplayName;
  105.     /**
  106.      * @ORM\Column(type="text", nullable=true)
  107.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  108.      */
  109.     private $teamplayDescription;
  110.     /**
  111.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  112.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  113.      */
  114.     private $teamplayPicture;
  115.     /**
  116.      * @ORM\Column(type="datetime")
  117.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  118.      */
  119.     private $teamplayStartDate;
  120.     /**
  121.      * @ORM\Column(type="datetime")
  122.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  123.      */
  124.     private $teamplayEndDate;
  125.     /**
  126.      * @ORM\Column(type="integer")
  127.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  128.      */
  129.     private $teamplayDuration;
  130.     // ═══════════════════════════════════════════════════════════════
  131.     // PERFORMANCES UTILISATEUR
  132.     // ═══════════════════════════════════════════════════════════════
  133.     /**
  134.      * @ORM\Column(type="integer", options={"default": 0})
  135.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  136.      */
  137.     private $totalPoints = 0;
  138.     /**
  139.      * @ORM\Column(type="integer", nullable=true)
  140.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  141.      */
  142.     private $userRank;
  143.     /**
  144.      * @ORM\Column(type="integer", nullable=true)
  145.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  146.      */
  147.     private $globalRank;
  148.     /**
  149.      * @ORM\Column(type="integer", options={"default": 0})
  150.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  151.      */
  152.     private $totalParticipants = 0;
  153.     // ═══════════════════════════════════════════════════════════════
  154.     // STATISTIQUES ACTIVITÉS UTILISATEUR
  155.     // ═══════════════════════════════════════════════════════════════
  156.     /**
  157.      * @ORM\Column(type="bigint", options={"default": 0})
  158.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  159.      */
  160.     private $totalSteps = 0;
  161.     /**
  162.      * @ORM\Column(type="decimal", precision=12, scale=2, options={"default": 0})
  163.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  164.      */
  165.     private $totalBikeDistance = 0;
  166.     /**
  167.      * @ORM\Column(type="decimal", precision=12, scale=2, options={"default": 0})
  168.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  169.      */
  170.     private $totalRunDistance = 0;
  171.     /**
  172.      * @ORM\Column(type="integer", options={"default": 0})
  173.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  174.      */
  175.     private $totalKinestexReps = 0;
  176.     /**
  177.      * @ORM\Column(type="integer", options={"default": 0})
  178.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  179.      */
  180.     private $totalKinestexDuration = 0;
  181.     /**
  182.      * @ORM\Column(type="integer", options={"default": 0})
  183.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  184.      */
  185.     private $totalKinestexSessions = 0;
  186.     /**
  187.      * @ORM\Column(type="integer", options={"default": 0})
  188.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  189.      */
  190.     private $totalQuizCorrect = 0;
  191.     /**
  192.      * @ORM\Column(type="integer", options={"default": 0})
  193.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  194.      */
  195.     private $totalQuizQuestions = 0;
  196.     /**
  197.      * @ORM\Column(type="integer", options={"default": 0})
  198.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  199.      */
  200.     private $totalVideosWatched = 0;
  201.     // ═══════════════════════════════════════════════════════════════
  202.     // INFORMATIONS ÉQUIPE (SNAPSHOT)
  203.     // ═══════════════════════════════════════════════════════════════
  204.     /**
  205.      * @ORM\Column(type="string", length=255, nullable=true)
  206.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  207.      */
  208.     private $teamName;
  209.     /**
  210.      * @ORM\ManyToOne(targetEntity=MediaObject::class)
  211.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  212.      */
  213.     private $teamPicture;
  214.     /**
  215.      * @ORM\Column(type="integer", options={"default": 0})
  216.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  217.      */
  218.     private $teamPoints = 0;
  219.     /**
  220.      * @ORM\Column(type="integer", nullable=true)
  221.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  222.      */
  223.     private $teamRank;
  224.     /**
  225.      * @ORM\Column(type="integer", options={"default": 0})
  226.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  227.      */
  228.     private $totalTeams = 0;
  229.     /**
  230.      * @ORM\Column(type="integer", options={"default": 0})
  231.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  232.      */
  233.     private $teamMembersCount = 0;
  234.     // ═══════════════════════════════════════════════════════════════
  235.     // STATISTIQUES ÉQUIPE
  236.     // ═══════════════════════════════════════════════════════════════
  237.     /**
  238.      * @ORM\Column(type="bigint", options={"default": 0})
  239.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  240.      */
  241.     private $teamTotalSteps = 0;
  242.     /**
  243.      * @ORM\Column(type="decimal", precision=12, scale=2, options={"default": 0})
  244.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  245.      */
  246.     private $teamTotalBikeDistance = 0;
  247.     /**
  248.      * @ORM\Column(type="decimal", precision=12, scale=2, options={"default": 0})
  249.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  250.      */
  251.     private $teamTotalRunDistance = 0;
  252.     /**
  253.      * @ORM\Column(type="integer", options={"default": 0})
  254.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  255.      */
  256.     private $teamTotalQuizCorrect = 0;
  257.     /**
  258.      * @ORM\Column(type="integer", options={"default": 0})
  259.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  260.      */
  261.     private $teamTotalVideosWatched = 0;
  262.     /**
  263.      * @ORM\Column(type="integer", options={"default": 0})
  264.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  265.      */
  266.     private $teamTotalKinestexSessions = 0;
  267.     // ═══════════════════════════════════════════════════════════════
  268.     // RÉSUMÉ DES TYPES DE CHALLENGES PRÉSENTS (NOUVEAU)
  269.     // ═══════════════════════════════════════════════════════════════
  270.     /**
  271.      * Tableau récapitulatif des types d'activités présents dans le Teamplay
  272.      * (quiz, bike, run, step, kinestex, video, etc.) + détail des exos Kinestex
  273.      * 
  274.      * @ORM\Column(type="json", nullable=true)
  275.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  276.      */
  277.     private $challengeTypesSummary = [];
  278.     // ═══════════════════════════════════════════════════════════════
  279.     // DÉTAILS CHALLENGES COMPLÉTÉS
  280.     // ═══════════════════════════════════════════════════════════════
  281.     /**
  282.      * @ORM\Column(type="json", nullable=true)
  283.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  284.      */
  285.     private $challengesData = [];
  286.     /**
  287.      * @ORM\Column(type="integer", options={"default": 0})
  288.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  289.      */
  290.     private $challengesCompletedCount = 0;
  291.     /**
  292.      * @ORM\Column(type="integer", options={"default": 0})
  293.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  294.      */
  295.     private $challengesTotalCount = 0;
  296.     // ═══════════════════════════════════════════════════════════════
  297.     // MÉTADONNÉES
  298.     // ═══════════════════════════════════════════════════════════════
  299.     /**
  300.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  301.      * @Gedmo\Timestampable(on="create")
  302.      * @Groups({"teamplay_recap:read"})
  303.      */
  304.     private $createdAt;
  305.     /**
  306.      * @ORM\Column(type="datetime", nullable=true)
  307.      * @Gedmo\Timestampable(on="update")
  308.      * @Groups({"teamplay_recap:read"})
  309.      */
  310.     private $updatedAt;
  311.     /**
  312.      * @ORM\Column(type="boolean", options={"default": true})
  313.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  314.      */
  315.     private $autoGenerated = true;
  316.     /**
  317.      * @ORM\Column(type="json", nullable=true)
  318.      * @Groups({"teamplay_recap:read", "teamplay_recap:write"})
  319.      */
  320.     private $extraData = [];
  321.     // ═══════════════════════════════════════════════════════════════
  322.     // GETTERS & SETTERS
  323.     // ═══════════════════════════════════════════════════════════════
  324.     public function getId(): ?int
  325.     {
  326.         return $this->id;
  327.     }
  328.     public function getUser(): ?User
  329.     {
  330.         return $this->user;
  331.     }
  332.     public function setUser(?User $user): self
  333.     {
  334.         $this->user = $user;
  335.         return $this;
  336.     }
  337.     public function getTeamplay(): ?Teamplay
  338.     {
  339.         return $this->teamplay;
  340.     }
  341.     public function setTeamplay(?Teamplay $teamplay): self
  342.     {
  343.         $this->teamplay = $teamplay;
  344.         return $this;
  345.     }
  346.     public function getTeam(): ?Team
  347.     {
  348.         return $this->team;
  349.     }
  350.     public function setTeam(?Team $team): self
  351.     {
  352.         $this->team = $team;
  353.         return $this;
  354.     }
  355.     public function getCompany(): ?Company
  356.     {
  357.         return $this->company;
  358.     }
  359.     public function setCompany(?Company $company): self
  360.     {
  361.         $this->company = $company;
  362.         return $this;
  363.     }
  364.     public function getTeamplayName(): ?string
  365.     {
  366.         return $this->teamplayName;
  367.     }
  368.     public function setTeamplayName(string $teamplayName): self
  369.     {
  370.         $this->teamplayName = $teamplayName;
  371.         return $this;
  372.     }
  373.     public function getTeamplayDescription(): ?string
  374.     {
  375.         return $this->teamplayDescription;
  376.     }
  377.     public function setTeamplayDescription(?string $teamplayDescription): self
  378.     {
  379.         $this->teamplayDescription = $teamplayDescription;
  380.         return $this;
  381.     }
  382.     public function getTeamplayPicture(): ?MediaObject
  383.     {
  384.         return $this->teamplayPicture;
  385.     }
  386.     public function setTeamplayPicture(?MediaObject $teamplayPicture): self
  387.     {
  388.         $this->teamplayPicture = $teamplayPicture;
  389.         return $this;
  390.     }
  391.     public function getTeamplayStartDate(): ?\DateTimeInterface
  392.     {
  393.         return $this->teamplayStartDate;
  394.     }
  395.     public function setTeamplayStartDate(\DateTimeInterface $teamplayStartDate): self
  396.     {
  397.         $this->teamplayStartDate = $teamplayStartDate;
  398.         return $this;
  399.     }
  400.     public function getTeamplayEndDate(): ?\DateTimeInterface
  401.     {
  402.         return $this->teamplayEndDate;
  403.     }
  404.     public function setTeamplayEndDate(\DateTimeInterface $teamplayEndDate): self
  405.     {
  406.         $this->teamplayEndDate = $teamplayEndDate;
  407.         return $this;
  408.     }
  409.     public function getTeamplayDuration(): ?int
  410.     {
  411.         return $this->teamplayDuration;
  412.     }
  413.     public function setTeamplayDuration(int $teamplayDuration): self
  414.     {
  415.         $this->teamplayDuration = $teamplayDuration;
  416.         return $this;
  417.     }
  418.     public function getTotalPoints(): int
  419.     {
  420.         return $this->totalPoints;
  421.     }
  422.     public function setTotalPoints(int $totalPoints): self
  423.     {
  424.         $this->totalPoints = $totalPoints;
  425.         return $this;
  426.     }
  427.     public function getUserRank(): ?int
  428.     {
  429.         return $this->userRank;
  430.     }
  431.     public function setUserRank(?int $userRank): self
  432.     {
  433.         $this->userRank = $userRank;
  434.         return $this;
  435.     }
  436.     public function getGlobalRank(): ?int
  437.     {
  438.         return $this->globalRank;
  439.     }
  440.     public function setGlobalRank(?int $globalRank): self
  441.     {
  442.         $this->globalRank = $globalRank;
  443.         return $this;
  444.     }
  445.     public function getTotalParticipants(): int
  446.     {
  447.         return $this->totalParticipants;
  448.     }
  449.     public function setTotalParticipants(int $totalParticipants): self
  450.     {
  451.         $this->totalParticipants = $totalParticipants;
  452.         return $this;
  453.     }
  454.     public function getTotalSteps(): int
  455.     {
  456.         return $this->totalSteps;
  457.     }
  458.     public function setTotalSteps(int $totalSteps): self
  459.     {
  460.         $this->totalSteps = $totalSteps;
  461.         return $this;
  462.     }
  463.     public function getTotalBikeDistance(): float
  464.     {
  465.         return (float) $this->totalBikeDistance;
  466.     }
  467.     public function setTotalBikeDistance(float $totalBikeDistance): self
  468.     {
  469.         $this->totalBikeDistance = $totalBikeDistance;
  470.         return $this;
  471.     }
  472.     /**
  473.      * @Groups({"teamplay_recap:read"})
  474.      */
  475.     public function getTotalBikeDistanceKm(): float
  476.     {
  477.         return round($this->getTotalBikeDistance() / 1000, 2);
  478.     }
  479.     public function getTotalRunDistance(): float
  480.     {
  481.         return (float) $this->totalRunDistance;
  482.     }
  483.     public function setTotalRunDistance(float $totalRunDistance): self
  484.     {
  485.         $this->totalRunDistance = $totalRunDistance;
  486.         return $this;
  487.     }
  488.     /**
  489.      * @Groups({"teamplay_recap:read"})
  490.      */
  491.     public function getTotalRunDistanceKm(): float
  492.     {
  493.         return round($this->getTotalRunDistance() / 1000, 2);
  494.     }
  495.     public function getTotalKinestexReps(): int
  496.     {
  497.         return $this->totalKinestexReps;
  498.     }
  499.     public function setTotalKinestexReps(int $totalKinestexReps): self
  500.     {
  501.         $this->totalKinestexReps = $totalKinestexReps;
  502.         return $this;
  503.     }
  504.     public function getTotalKinestexDuration(): int
  505.     {
  506.         return $this->totalKinestexDuration;
  507.     }
  508.     public function setTotalKinestexDuration(int $totalKinestexDuration): self
  509.     {
  510.         $this->totalKinestexDuration = $totalKinestexDuration;
  511.         return $this;
  512.     }
  513.     public function getTotalKinestexSessions(): int
  514.     {
  515.         return $this->totalKinestexSessions;
  516.     }
  517.     public function setTotalKinestexSessions(int $totalKinestexSessions): self
  518.     {
  519.         $this->totalKinestexSessions = $totalKinestexSessions;
  520.         return $this;
  521.     }
  522.     public function getTotalQuizCorrect(): int
  523.     {
  524.         return $this->totalQuizCorrect;
  525.     }
  526.     public function setTotalQuizCorrect(int $totalQuizCorrect): self
  527.     {
  528.         $this->totalQuizCorrect = $totalQuizCorrect;
  529.         return $this;
  530.     }
  531.     public function getTotalQuizQuestions(): int
  532.     {
  533.         return $this->totalQuizQuestions;
  534.     }
  535.     public function setTotalQuizQuestions(int $totalQuizQuestions): self
  536.     {
  537.         $this->totalQuizQuestions = $totalQuizQuestions;
  538.         return $this;
  539.     }
  540.     public function getTotalVideosWatched(): int
  541.     {
  542.         return $this->totalVideosWatched;
  543.     }
  544.     public function setTotalVideosWatched(int $totalVideosWatched): self
  545.     {
  546.         $this->totalVideosWatched = $totalVideosWatched;
  547.         return $this;
  548.     }
  549.     public function getTeamName(): ?string
  550.     {
  551.         return $this->teamName;
  552.     }
  553.     public function setTeamName(?string $teamName): self
  554.     {
  555.         $this->teamName = $teamName;
  556.         return $this;
  557.     }
  558.     public function getTeamPicture(): ?MediaObject
  559.     {
  560.         return $this->teamPicture;
  561.     }
  562.     public function setTeamPicture(?MediaObject $teamPicture): self
  563.     {
  564.         $this->teamPicture = $teamPicture;
  565.         return $this;
  566.     }
  567.     public function getTeamPoints(): int
  568.     {
  569.         return $this->teamPoints;
  570.     }
  571.     public function setTeamPoints(int $teamPoints): self
  572.     {
  573.         $this->teamPoints = $teamPoints;
  574.         return $this;
  575.     }
  576.     public function getTeamRank(): ?int
  577.     {
  578.         return $this->teamRank;
  579.     }
  580.     public function setTeamRank(?int $teamRank): self
  581.     {
  582.         $this->teamRank = $teamRank;
  583.         return $this;
  584.     }
  585.     public function getTotalTeams(): int
  586.     {
  587.         return $this->totalTeams;
  588.     }
  589.     public function setTotalTeams(int $totalTeams): self
  590.     {
  591.         $this->totalTeams = $totalTeams;
  592.         return $this;
  593.     }
  594.     public function getTeamMembersCount(): int
  595.     {
  596.         return $this->teamMembersCount;
  597.     }
  598.     public function setTeamMembersCount(int $teamMembersCount): self
  599.     {
  600.         $this->teamMembersCount = $teamMembersCount;
  601.         return $this;
  602.     }
  603.     public function getTeamTotalSteps(): int
  604.     {
  605.         return $this->teamTotalSteps;
  606.     }
  607.     public function setTeamTotalSteps(int $teamTotalSteps): self
  608.     {
  609.         $this->teamTotalSteps = $teamTotalSteps;
  610.         return $this;
  611.     }
  612.     public function getTeamTotalBikeDistance(): float
  613.     {
  614.         return (float) $this->teamTotalBikeDistance;
  615.     }
  616.     public function setTeamTotalBikeDistance(float $teamTotalBikeDistance): self
  617.     {
  618.         $this->teamTotalBikeDistance = $teamTotalBikeDistance;
  619.         return $this;
  620.     }
  621.     public function getTeamTotalRunDistance(): float
  622.     {
  623.         return (float) $this->teamTotalRunDistance;
  624.     }
  625.     public function setTeamTotalRunDistance(float $teamTotalRunDistance): self
  626.     {
  627.         $this->teamTotalRunDistance = $teamTotalRunDistance;
  628.         return $this;
  629.     }
  630.     public function getTeamTotalQuizCorrect(): int
  631.     {
  632.         return $this->teamTotalQuizCorrect;
  633.     }
  634.     public function setTeamTotalQuizCorrect(int $teamTotalQuizCorrect): self
  635.     {
  636.         $this->teamTotalQuizCorrect = $teamTotalQuizCorrect;
  637.         return $this;
  638.     }
  639.     public function getTeamTotalVideosWatched(): int
  640.     {
  641.         return $this->teamTotalVideosWatched;
  642.     }
  643.     public function setTeamTotalVideosWatched(int $teamTotalVideosWatched): self
  644.     {
  645.         $this->teamTotalVideosWatched = $teamTotalVideosWatched;
  646.         return $this;
  647.     }
  648.     public function getTeamTotalKinestexSessions(): int
  649.     {
  650.         return $this->teamTotalKinestexSessions;
  651.     }
  652.     public function setTeamTotalKinestexSessions(int $teamTotalKinestexSessions): self
  653.     {
  654.         $this->teamTotalKinestexSessions = $teamTotalKinestexSessions;
  655.         return $this;
  656.     }
  657.     public function getChallengeTypesSummary(): ?array
  658.     {
  659.         return $this->challengeTypesSummary;
  660.     }
  661.     public function setChallengeTypesSummary(?array $challengeTypesSummary): self
  662.     {
  663.         $this->challengeTypesSummary = $challengeTypesSummary;
  664.         return $this;
  665.     }
  666.     public function getChallengesData(): ?array
  667.     {
  668.         return $this->challengesData;
  669.     }
  670.     public function setChallengesData(?array $challengesData): self
  671.     {
  672.         $this->challengesData = $challengesData;
  673.         return $this;
  674.     }
  675.     public function getChallengesCompletedCount(): int
  676.     {
  677.         return $this->challengesCompletedCount;
  678.     }
  679.     public function setChallengesCompletedCount(int $challengesCompletedCount): self
  680.     {
  681.         $this->challengesCompletedCount = $challengesCompletedCount;
  682.         return $this;
  683.     }
  684.     public function getChallengesTotalCount(): int
  685.     {
  686.         return $this->challengesTotalCount;
  687.     }
  688.     public function setChallengesTotalCount(int $challengesTotalCount): self
  689.     {
  690.         $this->challengesTotalCount = $challengesTotalCount;
  691.         return $this;
  692.     }
  693.     /**
  694.      * @Groups({"teamplay_recap:read"})
  695.      */
  696.     public function getCompletionRate(): float
  697.     {
  698.         if ($this->challengesTotalCount === 0) {
  699.             return 0;
  700.         }
  701.         return round(($this->challengesCompletedCount / $this->challengesTotalCount) * 100, 2);
  702.     }
  703.     public function getCreatedAt(): ?\DateTimeInterface
  704.     {
  705.         return $this->createdAt;
  706.     }
  707.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  708.     {
  709.         $this->createdAt = $createdAt;
  710.         return $this;
  711.     }
  712.     public function getUpdatedAt(): ?\DateTimeInterface
  713.     {
  714.         return $this->updatedAt;
  715.     }
  716.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  717.     {
  718.         $this->updatedAt = $updatedAt;
  719.         return $this;
  720.     }
  721.     public function isAutoGenerated(): bool
  722.     {
  723.         return $this->autoGenerated;
  724.     }
  725.     public function setAutoGenerated(bool $autoGenerated): self
  726.     {
  727.         $this->autoGenerated = $autoGenerated;
  728.         return $this;
  729.     }
  730.     public function getExtraData(): ?array
  731.     {
  732.         return $this->extraData;
  733.     }
  734.     public function setExtraData(?array $extraData): self
  735.     {
  736.         $this->extraData = $extraData;
  737.         return $this;
  738.     }
  739.     /**
  740.      * URL directe de l'image du teamplay
  741.      * @Groups({"teamplay_recap:read"})
  742.      */
  743.     public function getTeamplayPictureUrl(): ?string
  744.     {
  745.         return $this->teamplayPicture ? $this->teamplayPicture->getContentUrl() : null;
  746.     }
  747.     /**
  748.      * URL directe de l'image de l'équipe
  749.      * @Groups({"teamplay_recap:read"})
  750.      */
  751.     public function getTeamPictureUrl(): ?string
  752.     {
  753.         return $this->teamPicture ? $this->teamPicture->getContentUrl() : null;
  754.     }
  755.     /**
  756.      * URL directe de l'avatar de l'utilisateur
  757.      * @Groups({"teamplay_recap:read"})
  758.      */
  759.     public function getUserPictureUrl(): ?string
  760.     {
  761.         if ($this->user && $this->user->getClient() && $this->user->getClient()->getAvatar()) {
  762.             return $this->user->getClient()->getAvatar()->getContentUrl();
  763.         }
  764.         return null;
  765.     }
  766. }