Expose authorised recorded book metrics without Timeline default filling
This commit is contained in:
parent
b7fe1e4fb9
commit
9568e7ec23
@ -89,6 +89,7 @@ public interface ISceneRepository
|
||||
Task UpdatePovCharacterAsync(int sceneId, int? povCharacterId, string source = "Author", decimal? confidence = null, string? evidence = null, string? suggestedName = null, bool overwriteAuthor = false);
|
||||
Task SaveFloorPlanLinkAsync(int sceneId, int? floorPlanId, int? initialFloorPlanFloorId);
|
||||
Task SavePurposesAsync(int sceneId, IEnumerable<int> purposeIds);
|
||||
Task<IReadOnlyList<SceneMetricValue>> ListRecordedMetricsByBookAsync(int bookId, int userId);
|
||||
Task SaveMetricValuesAsync(int sceneId, IEnumerable<SceneMetricValue> metricValues);
|
||||
Task SaveMetricValueAsync(int sceneId, int metricTypeId, int value);
|
||||
Task ArchiveAsync(int sceneId);
|
||||
@ -2644,6 +2645,12 @@ public sealed class SceneRepository(ISqlConnectionFactory connectionFactory) : I
|
||||
commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<SceneMetricValue>> ListRecordedMetricsByBookAsync(int bookId,int userId)
|
||||
{
|
||||
using var connection=connectionFactory.CreateConnection();
|
||||
return (await connection.QueryAsync<SceneMetricValue>("dbo.SceneMetric_ListRecordedForBook",new{BookID=bookId,UserID=userId},commandType:CommandType.StoredProcedure)).ToList();
|
||||
}
|
||||
|
||||
public async Task SaveMetricValuesAsync(int sceneId, IEnumerable<SceneMetricValue> metricValues)
|
||||
{
|
||||
using var connection = connectionFactory.CreateConnection();
|
||||
|
||||
28
PlotLine/Sql/244_WritingContextRecordedMetrics.sql
Normal file
28
PlotLine/Sql/244_WritingContextRecordedMetrics.sql
Normal file
@ -0,0 +1,28 @@
|
||||
-- Read-only projection: actual saved values, including custom metrics; no Timeline default filling.
|
||||
SET ANSI_NULLS ON;
|
||||
SET QUOTED_IDENTIFIER ON;
|
||||
GO
|
||||
CREATE OR ALTER PROCEDURE dbo.SceneMetric_ListRecordedForBook
|
||||
@BookID int,
|
||||
@UserID int
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
DECLARE @ProjectID int;
|
||||
SELECT @ProjectID=b.ProjectID
|
||||
FROM dbo.Books b
|
||||
WHERE b.BookID=@BookID
|
||||
AND EXISTS(SELECT 1 FROM dbo.ProjectUserAccess a WHERE a.ProjectID=b.ProjectID AND a.UserID=@UserID AND a.IsActive=1);
|
||||
IF @ProjectID IS NULL THROW 51000,'Book access denied',1;
|
||||
|
||||
SELECT stored.SceneID,stored.MetricTypeID,metric.MetricName,metric.MinValue,metric.MaxValue,
|
||||
metric.DefaultValue,metric.SortOrder,metric.IsActive,stored.Value,stored.Notes
|
||||
FROM dbo.SceneMetricValues stored
|
||||
INNER JOIN dbo.SceneMetricTypes metric ON metric.MetricTypeID=stored.MetricTypeID
|
||||
INNER JOIN dbo.Scenes scene ON scene.SceneID=stored.SceneID
|
||||
INNER JOIN dbo.Chapters chapter ON chapter.ChapterID=scene.ChapterID
|
||||
WHERE chapter.BookID=@BookID AND chapter.IsArchived=0 AND scene.IsArchived=0
|
||||
AND metric.IsActive=1 AND (metric.ProjectID IS NULL OR metric.ProjectID=@ProjectID)
|
||||
ORDER BY metric.SortOrder,metric.MetricName,chapter.SortOrder,chapter.ChapterNumber,scene.SortOrder,scene.SceneNumber,scene.SceneID;
|
||||
END;
|
||||
GO
|
||||
Loading…
x
Reference in New Issue
Block a user