Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Data/Models/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public enum ChannelStatus

public ChannelStatus Status { get; set; }

/// <summary>
/// Timestamp at which the channel transitioned to <see cref="ChannelStatus.Closed"/>.
/// Null while the channel is open or for channels closed before this column existed.
/// </summary>
public DateTimeOffset? ClosedAt { get; set; }

/// <summary>
/// Indicates if this channel was created by NodeGuard
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions src/Data/Repositories/ChannelRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public async Task<List<Channel>> GetAll()
{
using var applicationDbContext = _dbContextFactory.CreateDbContext();

type.SetUpdateDatetime();

//Automapper to avoid creation of entities
type = _mapper.Map<Channel, Channel>(type);

Expand Down Expand Up @@ -340,6 +342,7 @@ public async Task<List<Channel>> GetAllManagedByUserNodes(string loggedUserId)
}

channel.Status = Channel.ChannelStatus.Closed;
channel.ClosedAt = DateTimeOffset.UtcNow;

var markAsClosed = _repository.Update(channel, applicationDbContext);

Expand Down
1 change: 1 addition & 0 deletions src/Jobs/ChannelMonitorJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public async Task MarkClosedChannelsAsClosed(Node source, List<Channel>? channel
if (channel == null)
{
openChannel.Status = ChannelStatus.Closed;
openChannel.ClosedAt = DateTimeOffset.UtcNow;
await dbContext.SaveChangesAsync();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Jobs/NodeChannelSubscribeJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public async Task NodeUpdateManagement(ChannelEventUpdate channelEventUpdate, No
else
{
channelToClose.Status = Channel.ChannelStatus.Closed;
channelToClose.ClosedAt = DateTimeOffset.UtcNow;
var updateChannel = _channelRepository.Update(channelToClose);
if (!updateChannel.Item1)
{
Expand Down
Loading
Loading