AI Analysis: persist analysis on candidate profile
This commit is contained in:
@@ -23,6 +23,12 @@ class AIAnalysisController extends Controller
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$analysis = $this->aiService->analyze($candidate);
|
$analysis = $this->aiService->analyze($candidate);
|
||||||
|
|
||||||
|
// Persist the analysis on the candidate profile
|
||||||
|
$candidate->update([
|
||||||
|
'ai_analysis' => $analysis
|
||||||
|
]);
|
||||||
|
|
||||||
return response()->json($analysis);
|
return response()->json($analysis);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return response()->json(['error' => $e->getMessage()], 500);
|
return response()->json(['error' => $e->getMessage()], 500);
|
||||||
|
|||||||
@@ -9,11 +9,15 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
#[Fillable(['user_id', 'job_position_id', 'phone', 'linkedin_url', 'status', 'notes', 'cv_score', 'motivation_score', 'interview_score'])]
|
#[Fillable(['user_id', 'job_position_id', 'phone', 'linkedin_url', 'status', 'notes', 'cv_score', 'motivation_score', 'interview_score', 'ai_analysis'])]
|
||||||
class Candidate extends Model
|
class Candidate extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'ai_analysis' => 'array',
|
||||||
|
];
|
||||||
|
|
||||||
public function jobPosition(): BelongsTo
|
public function jobPosition(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(JobPosition::class);
|
return $this->belongsTo(JobPosition::class);
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('candidates', function (Blueprint $table) {
|
||||||
|
$table->json('ai_analysis')->nullable()->after('interview_score');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('candidates', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('ai_analysis');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -120,7 +120,7 @@ const updateAnswerScore = (answerId, score) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const aiAnalysis = ref(null);
|
const aiAnalysis = ref(props.candidate.ai_analysis || null);
|
||||||
const isAnalyzing = ref(false);
|
const isAnalyzing = ref(false);
|
||||||
|
|
||||||
const runAI = async () => {
|
const runAI = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user