File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public sealed partial class AdminController
1616 /// <response code="200"></response>
1717 /// <response code="401">Unauthorized</response>
1818 [ HttpGet ( "config" ) ]
19- [ ProducesResponseType < IAsyncEnumerable < ConfigurationItemDto > > ( StatusCodes . Status200OK , MediaTypeNames . Application . Json ) ] // Ok
19+ [ ProducesResponseType < ConfigurationItemDto [ ] > ( StatusCodes . Status200OK , MediaTypeNames . Application . Json ) ] // Ok
2020 public IAsyncEnumerable < ConfigurationItemDto > ConfigurationList ( [ FromServices ] IConfigurationService configurationService )
2121 {
2222 return configurationService
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public sealed partial class AdminController
1717 /// <response code="200">All online devices</response>
1818 /// <response code="401">Unauthorized</response>
1919 [ HttpGet ( "monitoring/onlineDevices" ) ]
20- [ ProducesResponseType < LegacyDataResponse < IEnumerable < AdminOnlineDeviceResponse > > > ( StatusCodes . Status200OK , MediaTypeNames . Application . Json ) ]
20+ [ ProducesResponseType < LegacyDataResponse < AdminOnlineDeviceResponse [ ] > > ( StatusCodes . Status200OK , MediaTypeNames . Application . Json ) ]
2121 public async Task < IActionResult > GetOnlineDevices ( )
2222 {
2323 var devicesOnline = _redis . RedisCollection < DeviceOnline > ( false ) ;
Original file line number Diff line number Diff line change 1- using Microsoft . AspNetCore . Mvc ;
1+ using System . Net . Mime ;
2+ using System . Runtime . CompilerServices ;
3+ using Microsoft . AspNetCore . Mvc ;
24using OpenShock . API . Models . Response ;
35
46namespace OpenShock . API . Controller . Sessions ;
57
68public sealed partial class SessionsController
79{
810 [ HttpGet ]
9- public async Task < IEnumerable < LoginSessionResponse > > ListSessions ( )
11+ [ ProducesResponseType < LoginSessionResponse [ ] > ( StatusCodes . Status200OK , MediaTypeNames . Application . Json ) ]
12+ public async IAsyncEnumerable < LoginSessionResponse > ListSessions ( [ EnumeratorCancellation ] CancellationToken cancellationToken )
1013 {
11- var sessions = await _sessionService . ListSessionsByUserIdAsync ( CurrentUser . Id ) ;
12-
13- return sessions . Select ( LoginSessionResponse . MapFrom ) ;
14+ await foreach ( var session in _sessionService . ListSessionsByUserIdAsync ( CurrentUser . Id ) . WithCancellation ( cancellationToken ) )
15+ {
16+ yield return LoginSessionResponse . MapFrom ( session ) ;
17+ }
1418 }
1519}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ public interface ISessionService
66{
77 public Task < CreateSessionResult > CreateSessionAsync ( Guid userId , string userAgent , string ipAddress ) ;
88
9- public Task < IReadOnlyList < LoginSession > > ListSessionsByUserIdAsync ( Guid userId ) ;
9+ public IAsyncEnumerable < LoginSession > ListSessionsByUserIdAsync ( Guid userId ) ;
1010
1111 public Task < LoginSession ? > GetSessionByTokenAsync ( string sessionToken ) ;
1212
Original file line number Diff line number Diff line change @@ -43,9 +43,9 @@ await _loginSessions.InsertAsync(new LoginSession
4343 return new CreateSessionResult ( id , token ) ;
4444 }
4545
46- public async Task < IReadOnlyList < LoginSession > > ListSessionsByUserIdAsync ( Guid userId )
46+ public IAsyncEnumerable < LoginSession > ListSessionsByUserIdAsync ( Guid userId )
4747 {
48- return await _loginSessions . Where ( x => x . UserId == userId ) . ToArrayAsync ( ) ;
48+ return _loginSessions . Where ( x => x . UserId == userId ) ;
4949 }
5050
5151 public async Task < LoginSession ? > GetSessionByTokenAsync ( string sessionToken )
You can’t perform that action at this time.
0 commit comments