59 lines
2.6 KiB
Transact-SQL
59 lines
2.6 KiB
Transact-SQL
SET ANSI_NULLS ON;
|
|
GO
|
|
SET QUOTED_IDENTIFIER ON;
|
|
GO
|
|
|
|
CREATE OR ALTER PROCEDURE dbo.SceneMetricType_AddMissingDefaultsForProject
|
|
@ProjectID int
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON;
|
|
|
|
MERGE dbo.SceneMetricTypes AS target
|
|
USING (VALUES
|
|
(N'Overall Intensity', N'General dramatic intensity for the scene.', 1, 10, 5, 10),
|
|
(N'Tension', N'Pressure, suspense, uncertainty, or conflict.', 1, 10, 5, 20),
|
|
(N'Emotional Weight', N'Emotional load carried by the scene.', 1, 10, 5, 30),
|
|
(N'Action', N'Physical action, movement, or event energy.', 1, 10, 3, 40),
|
|
(N'Darkness', N'Darkness, bleakness, fear, or threat.', 1, 10, 3, 50),
|
|
(N'Romance', N'Romantic focus or intimacy.', 1, 10, 1, 60),
|
|
(N'Sexual Charge', N'Sexual tension or sensual charge.', 1, 10, 1, 70),
|
|
(N'Violence', N'Violent action, injury, or threat.', 1, 10, 1, 80),
|
|
(N'Hope / Lightness', N'Hope, relief, warmth, or tonal lightness.', 1, 10, 4, 90),
|
|
(N'Comedy', N'Humour or comic relief.', 1, 10, 1, 100),
|
|
(N'Mystery', N'Questions, clue energy, and mystery pressure.', 1, 10, 5, 110)
|
|
) AS source (MetricName, Description, MinValue, MaxValue, DefaultValue, SortOrder)
|
|
ON target.ProjectID IS NULL AND target.MetricName = source.MetricName
|
|
WHEN NOT MATCHED THEN
|
|
INSERT (ProjectID, MetricName, Description, MinValue, MaxValue, DefaultValue, SortOrder, IsActive)
|
|
VALUES (NULL, source.MetricName, source.Description, source.MinValue, source.MaxValue, source.DefaultValue, source.SortOrder, 1);
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.ProjectTimelineSettings WHERE ProjectID = @ProjectID)
|
|
BEGIN
|
|
INSERT dbo.ProjectTimelineSettings
|
|
(ProjectID, ShowSceneCards, ShowMetricShape, ShowPlotLines, ShowStoryAssets, ShowCharacterAppearances, ShowWarnings)
|
|
VALUES
|
|
(@ProjectID, 1, 1, 1, 1, 1, 1);
|
|
END;
|
|
|
|
INSERT dbo.ProjectTimelineMetricSettings (ProjectID, MetricTypeID, SortOrder)
|
|
SELECT @ProjectID, mt.MetricTypeID, mt.SortOrder
|
|
FROM dbo.SceneMetricTypes mt
|
|
WHERE mt.ProjectID IS NULL
|
|
AND mt.IsActive = 1
|
|
AND mt.MetricName IN
|
|
(
|
|
N'Overall Intensity', N'Tension', N'Emotional Weight', N'Action', N'Darkness',
|
|
N'Romance', N'Sexual Charge', N'Violence', N'Hope / Lightness', N'Comedy', N'Mystery'
|
|
)
|
|
AND NOT EXISTS
|
|
(
|
|
SELECT 1
|
|
FROM dbo.ProjectTimelineMetricSettings ptms
|
|
INNER JOIN dbo.SceneMetricTypes existing ON existing.MetricTypeID = ptms.MetricTypeID
|
|
WHERE ptms.ProjectID = @ProjectID
|
|
AND LOWER(existing.MetricName) = LOWER(mt.MetricName)
|
|
);
|
|
END;
|
|
GO
|