mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-10 22:01:16 +00:00
All checks were successful
continuous-integration/drone/push Build is passing
Manual override training (GroupingRule): - Learn patterns from manual group creation (common filename prefix or creator) - Apply learned rules as first auto-grouping pass (highest confidence after albums) - GroupingRule model stores pattern, channel, signal type, confidence Hash verification after upload: - Re-hash upload files on disk before indexing to catch disk corruption - Creates HASH_MISMATCH notification on discrepancy Grouping conflict detection: - After all grouping passes, check if grouped packages match rules from different groups - Creates GROUPING_CONFLICT notification for manual review Per-channel grouping flags: - Add autoGroupEnabled boolean to TelegramChannel (default true) - Auto-grouping passes (all except album) gated behind this flag - Album grouping always runs as it reflects Telegram's native behavior Full-text search (tsvector): - Add searchVector tsvector column with GIN index and auto-update trigger - Backfill 1870 existing packages - FTS with ts_rank for ranked results, ILIKE fallback for short/failed queries - Applied to both web app and bot search Bot group awareness: - /group <query> — view group info or search groups by name - /sendgroup <id> — send all packages in a group to linked Telegram account Bulk repair: - repairPackageAction clears dest info and resets watermark for re-processing - Repair button in notification bell for MISSING_PART and HASH_MISMATCH alerts - /api/notifications/repair endpoint Retroactive category re-tagging: - When channel category changes, auto-update tags on all existing packages - Removes old category tag, adds new one Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
48 lines
1.9 KiB
PL/PgSQL
48 lines
1.9 KiB
PL/PgSQL
-- AlterTable: add autoGroupEnabled to telegram_channels
|
|
ALTER TABLE "telegram_channels" ADD COLUMN "autoGroupEnabled" BOOLEAN NOT NULL DEFAULT true;
|
|
|
|
-- CreateTable: grouping_rules
|
|
CREATE TABLE "grouping_rules" (
|
|
"id" TEXT NOT NULL,
|
|
"sourceChannelId" TEXT NOT NULL,
|
|
"pattern" TEXT NOT NULL,
|
|
"signalType" "GroupingSource" NOT NULL,
|
|
"confidence" DOUBLE PRECISION NOT NULL DEFAULT 1.0,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"createdByGroupId" TEXT,
|
|
|
|
CONSTRAINT "grouping_rules_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "grouping_rules_sourceChannelId_idx" ON "grouping_rules"("sourceChannelId");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "grouping_rules" ADD CONSTRAINT "grouping_rules_sourceChannelId_fkey" FOREIGN KEY ("sourceChannelId") REFERENCES "telegram_channels"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- Full-text search: add tsvector column and GIN index
|
|
ALTER TABLE "packages" ADD COLUMN IF NOT EXISTS "searchVector" tsvector;
|
|
|
|
UPDATE "packages" SET "searchVector" = to_tsvector('english',
|
|
coalesce("fileName", '') || ' ' || coalesce("creator", '') || ' ' || coalesce("sourceCaption", '')
|
|
) WHERE "searchVector" IS NULL;
|
|
|
|
CREATE INDEX IF NOT EXISTS "packages_search_vector_idx" ON "packages" USING GIN ("searchVector");
|
|
|
|
-- Trigger to auto-update searchVector on insert/update
|
|
CREATE OR REPLACE FUNCTION packages_search_vector_update() RETURNS trigger AS $$
|
|
BEGIN
|
|
NEW."searchVector" := to_tsvector('english',
|
|
coalesce(NEW."fileName", '') || ' ' || coalesce(NEW."creator", '') || ' ' || coalesce(NEW."sourceCaption", '')
|
|
);
|
|
RETURN NEW;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
|
|
DROP TRIGGER IF EXISTS packages_search_vector_trigger ON "packages";
|
|
CREATE TRIGGER packages_search_vector_trigger
|
|
BEFORE INSERT OR UPDATE OF "fileName", "creator", "sourceCaption"
|
|
ON "packages"
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION packages_search_vector_update();
|