Spaces:
Running
Running
Commit ·
1b321bd
1
Parent(s): 0a579ad
feat: optimize canvas load and save using lazy loading and delta upserts
Browse filesFiles changed (6)
32 unmodified lines3334353637383932 unmodified lines public double? Width { get; set; } public double? Height { get; set; } public string? Data { get; set; } public bool? HasLargeData { get; set; } }
public class EdgeDto8 unmodified lines910111213148 unmodified lines Task<TaskNodeResponseDto> CreateAsync(CreateTaskNodeDto dto); Task<TaskNodeResponseDto?> UpdateAsync(Guid id, UpdateTaskNodeDto dto); Task<bool> DeleteAsync(Guid id); Task<string?> GetNodeDataAsync(Guid id); }}112 unmodified lines113114115116116117118119120118119120121122123124125126127128129130121122123124125126127128129130131132133134135136137138112 unmodified lines CreatedAt = graph.CreatedAt, IsShared = isShared, Permission = permission, Nodes = graph.Nodes.Select(n => new NodeDto Nodes = graph.Nodes.Select(n => { bool hasLarge = n.Data != null && n.Data.Length > 2000; return new NodeDto { Id = n.Id, Label = n.Label, PosX = n.PosX, PosY = n.PosY, Type = n.Type, State = (int)n.State, Decision = n.Decision, Description = n.Description, Color = n.Color, IsPinned = n.IsPinned, Width = n.Width, Height = n.Height, Data = n.Data Id = n.Id, Label = n.Label, PosX = n.PosX, PosY = n.PosY, Type = n.Type, State = (int)n.State, Decision = n.Decision, Description = n.Description, Color = n.Color, IsPinned = n.IsPinned, Width = n.Width, Height = n.Height, Data = hasLarge ? null : n.Data, HasLargeData = hasLarge }; }).ToList(), Edges = graph.Edges.Select(e => new EdgeDto {66 unmodified lines67686970717273747576777866 unmodified lines return await _repo.DeleteAsync(id); }
public async Task<string?> GetNodeDataAsync(Guid id) { var node = await _repo.GetByIdAsync(id); return node?.Data; }
private static TaskNodeResponseDto MapToDto(TaskNode node) => new() { Id = node.Id,99 unmodified lines10010110210310410310510610710810999 unmodified lines existingNode.IsPinned = node.IsPinned; existingNode.Width = node.Width; existingNode.Height = node.Height; if (node.Data != null) { existingNode.Data = node.Data; existingNode.Data = node.Data; } } else {58 unmodified lines596061626364656667686970717273747558 unmodified lines if (!result) return NotFound(); return NoContent(); }
[HttpGet("{id:guid}/data")] public async Task<ActionResult<object>> GetNodeData(Guid id) { var nodeData = await _service.GetNodeDataAsync(id); if (nodeData is null) { var node = await _service.GetByIdAsync(id); if (node is null) return NotFound(); } return Ok(new { data = nodeData }); } }}FlowAPI.Application/DTOs/Graph/GraphDtos.cs+1
FlowAPI.Application/Interfaces/ITaskNodeService.cs+1
FlowAPI.Application/Services/GraphService.cs+19-14
FlowAPI.Application/Services/TaskNodeService.cs+6
FlowAPI.Infrastructure/Repositories/GraphRepository.cs+4-1
FlowAPI/Controllers/TaskNodesController.cs+12