check_duplicates.php's logic moves to services/SimilarTicketService.php (used next by the MCP find_similar_tickets tool). Fixes found while testing it: - Non-admins never got matches: the query had no `t` alias but the visibility filter's SQL uses t.*, so it failed and the error was swallowed into "no duplicates". - The word-overlap scoring could never fire, since candidates were only whole-title substring or SOUNDEX matches. Tickets sharing a significant word (4+ letters) are now candidates too; overlap needs 2+ shared words so one common word (e.g. every automated ticket's [problem] tag) isn't a match. - SOUNDEX compared PHP's 4-char code (effectively the first word) with MariaDB's full-length code: the SQL side almost never matched, and the scorer marked any two titles sharing a first word as "sounds alike". Both sides now use SQL SOUNDEX on the full title. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MGDKHiU5RJdo3dqQUDow3X
22 lines
609 B
PHP
22 lines
609 B
PHP
<?php
|
|
|
|
/**
|
|
* Check for duplicate tickets API
|
|
*
|
|
* Searches for tickets with similar titles using LIKE and SOUNDEX
|
|
*/
|
|
|
|
require_once __DIR__ . '/bootstrap.php';
|
|
require_once dirname(__DIR__) . '/helpers/ResponseHelper.php';
|
|
require_once dirname(__DIR__) . '/services/SimilarTicketService.php';
|
|
|
|
// Only accept GET requests
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
|
|
ResponseHelper::error('Method not allowed', 405);
|
|
}
|
|
|
|
// Get title parameter
|
|
$title = isset($_GET['title']) ? trim($_GET['title']) : '';
|
|
|
|
ResponseHelper::success(['duplicates' => SimilarTicketService::find($conn, $currentUser, $title)]);
|