src/Entity/CRM/CallEvaluation.php line 13
<?phpnamespace App\Entity\CRM;use App\Enum\CallEvaluationStatus;use App\Enum\SentimentLabel;use App\Repository\CRM\CallEvaluationRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: CallEvaluationRepository::class)]#[ORM\Table(name: 'call_evaluation')]class CallEvaluation{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\OneToOne(inversedBy: 'evaluation', targetEntity: TranscriptionJob::class)]#[ORM\JoinColumn(name: 'transcription_job_id', nullable: false, unique: true, onDelete: 'CASCADE')]private ?TranscriptionJob $transcriptionJob = null;#[ORM\ManyToOne]#[ORM\JoinColumn(name: 'tenant_id', nullable: true, onDelete: 'SET NULL')]private ?Branch $tenant = null;#[ORM\Column(length: 24, enumType: CallEvaluationStatus::class)]private CallEvaluationStatus $status = CallEvaluationStatus::PENDING;// --- SPRZEDAŻ ---#[ORM\Column(type: Types::SMALLINT, nullable: true)]private ?int $salesScore = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $salesAssessment = null;/*** @var array<int, string>|null*/#[ORM\Column(type: Types::JSON, nullable: true)]private ?array $keyPoints = null;/*** @var array<int, string>|null*/#[ORM\Column(type: Types::JSON, nullable: true)]private ?array $redFlags = null;// --- SENTYMENT ---#[ORM\Column(length: 16, nullable: true, enumType: SentimentLabel::class)]private ?SentimentLabel $sentimentLabel = null;#[ORM\Column(type: Types::SMALLINT, nullable: true)]private ?int $sentimentScore = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $sentimentRationale = null;// --- OCENA CAŁOŚCIOWA ---#[ORM\Column(type: Types::SMALLINT, nullable: true)]private ?int $overallScore = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $overallSummary = null;// --- METADANE WYWOŁANIA ---#[ORM\Column(length: 64, nullable: true)]private ?string $model = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $rawResponse = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $error = null;#[ORM\Column(type: Types::SMALLINT)]private int $attempts = 0;#[ORM\Column(type: Types::INTEGER, nullable: true)]private ?int $durationMs = null;#[ORM\Column(type: Types::SMALLINT)]private int $chunkCount = 1;// --- ŚLAD WERSJI PROMPTÓW (audit) ---#[ORM\ManyToOne(targetEntity: PromptTemplateVersion::class)]#[ORM\JoinColumn(name: 'prompt_system_version_id', nullable: true, onDelete: 'SET NULL')]private ?PromptTemplateVersion $promptSystemVersion = null;#[ORM\ManyToOne(targetEntity: PromptTemplateVersion::class)]#[ORM\JoinColumn(name: 'prompt_sales_version_id', nullable: true, onDelete: 'SET NULL')]private ?PromptTemplateVersion $promptSalesVersion = null;#[ORM\ManyToOne(targetEntity: PromptTemplateVersion::class)]#[ORM\JoinColumn(name: 'prompt_sentiment_version_id', nullable: true, onDelete: 'SET NULL')]private ?PromptTemplateVersion $promptSentimentVersion = null;#[ORM\ManyToOne(targetEntity: PromptTemplateVersion::class)]#[ORM\JoinColumn(name: 'prompt_overall_version_id', nullable: true, onDelete: 'SET NULL')]private ?PromptTemplateVersion $promptOverallVersion = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private \DateTimeInterface $createdAt;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $evaluatedAt = null;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $lockedAt = null;#[ORM\Column(length: 64, nullable: true)]private ?string $lockedBy = null;public function __construct(){$this->createdAt = new \DateTimeImmutable();}public function __toString(): string{$jobLabel = $this->transcriptionJob !== null ? (string) $this->transcriptionJob : '?';return sprintf('Ocena AI: %s', $jobLabel);}public function getId(): ?int{return $this->id;}public function getTranscriptionJob(): ?TranscriptionJob{return $this->transcriptionJob;}public function setTranscriptionJob(?TranscriptionJob $transcriptionJob): static{$this->transcriptionJob = $transcriptionJob;return $this;}public function getTenant(): ?Branch{return $this->tenant;}public function setTenant(?Branch $tenant): static{$this->tenant = $tenant;return $this;}public function getStatus(): CallEvaluationStatus{return $this->status;}public function setStatus(CallEvaluationStatus $status): static{$this->status = $status;return $this;}public function getSalesScore(): ?int{return $this->salesScore;}public function setSalesScore(?int $salesScore): static{$this->salesScore = $salesScore !== null ? $this->clampScore($salesScore, 0, 100) : null;return $this;}public function getSalesAssessment(): ?string{return $this->salesAssessment;}public function setSalesAssessment(?string $salesAssessment): static{$this->salesAssessment = $salesAssessment;return $this;}/*** @return array<int, string>|null*/public function getKeyPoints(): ?array{return $this->keyPoints;}/*** @param array<int, string>|null $keyPoints*/public function setKeyPoints(?array $keyPoints): static{$this->keyPoints = $keyPoints;return $this;}/*** @return array<int, string>|null*/public function getRedFlags(): ?array{return $this->redFlags;}/*** @param array<int, string>|null $redFlags*/public function setRedFlags(?array $redFlags): static{$this->redFlags = $redFlags;return $this;}public function getSentimentLabel(): ?SentimentLabel{return $this->sentimentLabel;}public function setSentimentLabel(?SentimentLabel $sentimentLabel): static{$this->sentimentLabel = $sentimentLabel;return $this;}public function getSentimentScore(): ?int{return $this->sentimentScore;}public function setSentimentScore(?int $sentimentScore): static{$this->sentimentScore = $sentimentScore !== null ? $this->clampScore($sentimentScore, -100, 100) : null;return $this;}public function getSentimentRationale(): ?string{return $this->sentimentRationale;}public function setSentimentRationale(?string $sentimentRationale): static{$this->sentimentRationale = $sentimentRationale;return $this;}public function getOverallScore(): ?int{return $this->overallScore;}public function setOverallScore(?int $overallScore): static{$this->overallScore = $overallScore !== null ? $this->clampScore($overallScore, 0, 100) : null;return $this;}public function getOverallSummary(): ?string{return $this->overallSummary;}public function setOverallSummary(?string $overallSummary): static{$this->overallSummary = $overallSummary;return $this;}public function getModel(): ?string{return $this->model;}public function setModel(?string $model): static{$this->model = $model;return $this;}public function getRawResponse(): ?string{return $this->rawResponse;}public function setRawResponse(?string $rawResponse): static{$this->rawResponse = $rawResponse;return $this;}public function getError(): ?string{return $this->error;}public function setError(?string $error): static{$this->error = $error;return $this;}public function getAttempts(): int{return $this->attempts;}public function setAttempts(int $attempts): static{$this->attempts = max(0, $attempts);return $this;}public function incrementAttempts(int $delta = 1): static{$this->attempts = max(0, $this->attempts + $delta);return $this;}public function getDurationMs(): ?int{return $this->durationMs;}public function setDurationMs(?int $durationMs): static{$this->durationMs = $durationMs;return $this;}public function getChunkCount(): int{return $this->chunkCount;}public function setChunkCount(int $chunkCount): static{$this->chunkCount = max(1, $chunkCount);return $this;}public function getPromptSystemVersion(): ?PromptTemplateVersion{return $this->promptSystemVersion;}public function setPromptSystemVersion(?PromptTemplateVersion $promptSystemVersion): static{$this->promptSystemVersion = $promptSystemVersion;return $this;}public function getPromptSalesVersion(): ?PromptTemplateVersion{return $this->promptSalesVersion;}public function setPromptSalesVersion(?PromptTemplateVersion $promptSalesVersion): static{$this->promptSalesVersion = $promptSalesVersion;return $this;}public function getPromptSentimentVersion(): ?PromptTemplateVersion{return $this->promptSentimentVersion;}public function setPromptSentimentVersion(?PromptTemplateVersion $promptSentimentVersion): static{$this->promptSentimentVersion = $promptSentimentVersion;return $this;}public function getPromptOverallVersion(): ?PromptTemplateVersion{return $this->promptOverallVersion;}public function setPromptOverallVersion(?PromptTemplateVersion $promptOverallVersion): static{$this->promptOverallVersion = $promptOverallVersion;return $this;}public function getCreatedAt(): \DateTimeInterface{return $this->createdAt;}public function setCreatedAt(\DateTimeInterface $createdAt): static{$this->createdAt = $createdAt;return $this;}public function getEvaluatedAt(): ?\DateTimeInterface{return $this->evaluatedAt;}public function setEvaluatedAt(?\DateTimeInterface $evaluatedAt): static{$this->evaluatedAt = $evaluatedAt;return $this;}public function getLockedAt(): ?\DateTimeInterface{return $this->lockedAt;}public function setLockedAt(?\DateTimeInterface $lockedAt): static{$this->lockedAt = $lockedAt;return $this;}public function getLockedBy(): ?string{return $this->lockedBy;}public function setLockedBy(?string $lockedBy): static{$this->lockedBy = $lockedBy;return $this;}private function clampScore(int $value, int $min, int $max): int{return max($min, min($max, $value));}}