From 7e92e35991627a0bbf862687554541e2e352e3d5 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 4 May 2026 09:24:45 -0400 Subject: [PATCH] Point search pipeline at Search2 table and *2 procs for v5 POC Re-target all search reads, writes, and stored proc calls to dbo.Search2 / SubmitSearch2 / StartSearch2 / CompleteSearch2 / ResetPartialSearches2 so the POC can run side-by-side with prod against the same QA database without contending on the Search table or its procs. Standalone deployment SQL for the new table and procs lives in OLD/sql/ and must be run against the target DB before the POC apps are started. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Process/LotFinderDB.SearchManagement.cs | 10 +++---- OLD/WorkerService/Process/LotFinderDBExt.cs | 8 +++--- OLD/sql/CompleteSearch2.sql | 22 +++++++++++++++ OLD/sql/ResetPartialSearches2.sql | 10 +++++++ OLD/sql/Search2.sql | 17 +++++++++++ OLD/sql/StartSearch2.sql | 9 ++++++ OLD/sql/SubmitSearch2.sql | 28 +++++++++++++++++++ 7 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 OLD/sql/CompleteSearch2.sql create mode 100644 OLD/sql/ResetPartialSearches2.sql create mode 100644 OLD/sql/Search2.sql create mode 100644 OLD/sql/StartSearch2.sql create mode 100644 OLD/sql/SubmitSearch2.sql diff --git a/OLD/DataModel/Process/LotFinderDB.SearchManagement.cs b/OLD/DataModel/Process/LotFinderDB.SearchManagement.cs index 5469c78..73d6d48 100755 --- a/OLD/DataModel/Process/LotFinderDB.SearchManagement.cs +++ b/OLD/DataModel/Process/LotFinderDB.SearchManagement.cs @@ -25,7 +25,7 @@ namespace DataModel.Process s.SubmitDT, s.StartDT, s.EndDT - FROM dbo.Search s + FROM dbo.Search2 s WHERE s.UserName = @userName ORDER BY s.SubmitDT"; @@ -65,7 +65,7 @@ namespace DataModel.Process s.SubmitDT, s.StartDT, s.EndDT - FROM dbo.Search s + FROM dbo.Search2 s WHERE s.Status < 3 ORDER BY s.SubmitDT"; @@ -104,7 +104,7 @@ namespace DataModel.Process s.StartDT, s.EndDT, s.Criteria as CriteriaJSON - FROM dbo.Search s + FROM dbo.Search2 s WHERE s.ID = @id"; /// @@ -143,7 +143,7 @@ namespace DataModel.Process /// private const string SQL_GET_SEARCH_RESULTS = @" SELECT s.Results - FROM dbo.Search AS s + FROM dbo.Search2 AS s WHERE s.ID = @id"; /// @@ -187,7 +187,7 @@ namespace DataModel.Process using (SqlConnection connection = GetConnection()) { - using (SqlCommand command = new SqlCommand("SubmitSearch", connection)) + using (SqlCommand command = new SqlCommand("SubmitSearch2", connection)) { command.CommandType = CommandType.StoredProcedure; diff --git a/OLD/WorkerService/Process/LotFinderDBExt.cs b/OLD/WorkerService/Process/LotFinderDBExt.cs index 134d593..7bc08ab 100755 --- a/OLD/WorkerService/Process/LotFinderDBExt.cs +++ b/OLD/WorkerService/Process/LotFinderDBExt.cs @@ -29,7 +29,7 @@ namespace WorkerService.Process s.StartDT, s.EndDT, s.Criteria AS CriteriaJSON - FROM dbo.Search s + FROM dbo.Search2 s WHERE s.Status = 1 ORDER BY s.SubmitDT"; @@ -71,7 +71,7 @@ namespace WorkerService.Process { using (SqlConnection connection = GetConnection()) { - connection.Execute("ResetPartialSearches", commandType: CommandType.StoredProcedure); + connection.Execute("ResetPartialSearches2", commandType: CommandType.StoredProcedure); } } catch (Exception error) @@ -94,7 +94,7 @@ namespace WorkerService.Process using (SqlConnection connection = GetConnection()) { - connection.Execute("StartSearch", new { p_SearchID = search.ID }, commandType: CommandType.StoredProcedure); + connection.Execute("StartSearch2", new { p_SearchID = search.ID }, commandType: CommandType.StoredProcedure); } } catch (Exception error) @@ -117,7 +117,7 @@ namespace WorkerService.Process using (SqlConnection connection = GetConnection()) { - connection.Execute("CompleteSearch", new { p_SearchID = search.ID, p_WasSuccessful = wasSuccessful, p_Results = search.Results }, commandType: CommandType.StoredProcedure); + connection.Execute("CompleteSearch2", new { p_SearchID = search.ID, p_WasSuccessful = wasSuccessful, p_Results = search.Results }, commandType: CommandType.StoredProcedure); } } catch (Exception error) diff --git a/OLD/sql/CompleteSearch2.sql b/OLD/sql/CompleteSearch2.sql new file mode 100644 index 0000000..a1371d9 --- /dev/null +++ b/OLD/sql/CompleteSearch2.sql @@ -0,0 +1,22 @@ +CREATE PROCEDURE [dbo].[CompleteSearch2] ( + @p_SearchID INT, + @p_WasSuccessful BIT, + @p_Results VARBINARY(MAX) + ) +AS + DECLARE @v_Status INT; + + BEGIN + --Determine status code + SET @v_Status = CASE @p_WasSuccessful + WHEN 1 THEN 3 + ELSE 4 + END; + + --Update search status and results + UPDATE dbo.Search2 + SET Status = @v_Status, + Results = @p_Results, + EndDT = GETDATE() + WHERE ID = @p_SearchID; + END \ No newline at end of file diff --git a/OLD/sql/ResetPartialSearches2.sql b/OLD/sql/ResetPartialSearches2.sql new file mode 100644 index 0000000..bc3d67b --- /dev/null +++ b/OLD/sql/ResetPartialSearches2.sql @@ -0,0 +1,10 @@ +CREATE PROCEDURE [dbo].[ResetPartialSearches2] +AS + BEGIN + --Reset status and start timestamp for searches begun but not finished + UPDATE dbo.Search2 + SET Status = 1, + StartDT = NULL + WHERE StartDT IS NOT NULL AND + EndDT IS NULL; + END \ No newline at end of file diff --git a/OLD/sql/Search2.sql b/OLD/sql/Search2.sql new file mode 100644 index 0000000..08c8ab5 --- /dev/null +++ b/OLD/sql/Search2.sql @@ -0,0 +1,17 @@ +CREATE TABLE [dbo].[Search2] +( + [ID] INT IDENTITY(1,1) NOT NULL, + [UserName] VARCHAR(128) NOT NULL, + [Name] VARCHAR(128) NULL, + [Status] SMALLINT NOT NULL, + [SubmitDT] DATETIME NULL, + [StartDT] DATETIME NULL, + [EndDT] DATETIME NULL, + [Criteria] VARCHAR(MAX) NULL, + [Results] VARBINARY(MAX) NULL, + CONSTRAINT [PK_Search2] PRIMARY KEY CLUSTERED([ID]) +) + +GO + +CREATE INDEX [IX_Search2_UserName] ON [dbo].[Search2] ([UserName]) diff --git a/OLD/sql/StartSearch2.sql b/OLD/sql/StartSearch2.sql new file mode 100644 index 0000000..0369669 --- /dev/null +++ b/OLD/sql/StartSearch2.sql @@ -0,0 +1,9 @@ +CREATE PROCEDURE [dbo].[StartSearch2] (@p_SearchID INT) +AS + BEGIN + --Update search status and start timestamp + UPDATE dbo.Search2 + SET Status = 2, + StartDT = GETDATE() + WHERE ID = @p_SearchID; + END \ No newline at end of file diff --git a/OLD/sql/SubmitSearch2.sql b/OLD/sql/SubmitSearch2.sql new file mode 100644 index 0000000..7d986ec --- /dev/null +++ b/OLD/sql/SubmitSearch2.sql @@ -0,0 +1,28 @@ +CREATE PROCEDURE [dbo].[SubmitSearch2] ( + @p_UserName VARCHAR(128), + @p_Name VARCHAR(128), + @p_Criteria VARCHAR(MAX), + @o_SearchID INT OUTPUT + ) +AS + BEGIN + --Insert new search record + INSERT INTO Search2 + ( + UserName, + Name, + Status, + SubmitDT, + Criteria + ) + VALUES ( + @p_UserName, + @p_Name, + 1, + GETDATE(), + @p_Criteria + ); + + --Get assigned auto-ID + SET @o_SearchID = SCOPE_IDENTITY(); + END \ No newline at end of file