Skip to content

Commit

Permalink
Improve performance (#140)
Browse files Browse the repository at this point in the history
Clean up code
  • Loading branch information
Fosol authored Aug 12, 2024
1 parent 107652c commit 2847382
Show file tree
Hide file tree
Showing 38 changed files with 923 additions and 138 deletions.
8 changes: 4 additions & 4 deletions src/api/Areas/Admin/Controllers/OrganizationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public IActionResult Find()
}

/// <summary>
///
/// Get the organization for the specified 'id'.
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Expand All @@ -81,7 +81,7 @@ public IActionResult GetForId(int id)
}

/// <summary>
///
/// Add a new organization to the database.
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Expand All @@ -103,7 +103,7 @@ public IActionResult Add(OrganizationModel model)
}

/// <summary>
///
/// Update the organization specified.
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Expand All @@ -126,7 +126,7 @@ public IActionResult Update(OrganizationModel model)
}

/// <summary>
///
/// Delete the organization specified.
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Expand Down
8 changes: 4 additions & 4 deletions src/api/Areas/Admin/Controllers/RoleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public IActionResult Find()
}

/// <summary>
///
/// Get the role for the specified 'id'.
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Expand All @@ -79,7 +79,7 @@ public IActionResult GetForId(int id)
}

/// <summary>
///
/// Add a new role to the database.
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Expand All @@ -97,7 +97,7 @@ public IActionResult Add(RoleModel model)
}

/// <summary>
///
/// Update the role specified.
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Expand All @@ -115,7 +115,7 @@ public IActionResult Update(RoleModel model)
}

/// <summary>
///
/// Delete the role specified.
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Expand Down
8 changes: 4 additions & 4 deletions src/api/Areas/Admin/Controllers/TenantController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public IActionResult Find()
}

/// <summary>
///
/// Get the tenant for the specified 'id'.
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Expand All @@ -79,7 +79,7 @@ public IActionResult GetForId(int id)
}

/// <summary>
///
/// Add a new tenant to the database.
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Expand All @@ -100,7 +100,7 @@ public IActionResult Add(TenantModel model)
}

/// <summary>
///
/// Update the tenant specified.
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Expand All @@ -123,7 +123,7 @@ public IActionResult Update(TenantModel model)
}

/// <summary>
///
/// Delete the tenant specified.
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Expand Down
10 changes: 3 additions & 7 deletions src/api/Areas/Dashboard/Controllers/FileSystemItemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
using HSB.DAL.Services;
using HSB.Keycloak;
using HSB.Keycloak.Extensions;
using HSB.Models;

using Swashbuckle.AspNetCore.Annotations;
using HSB.Models.Dashboard;

namespace HSB.API.Areas.Hsb.Controllers;
namespace HSB.API.Areas.Dashboard.Controllers;

/// <summary>
/// FileSystemItemController class, provides endpoints for file system items.
Expand All @@ -27,7 +27,6 @@ namespace HSB.API.Areas.Hsb.Controllers;
public class FileSystemItemController : ControllerBase
{
#region Variables
private readonly ILogger _logger;
private readonly IFileSystemItemService _fileSystemItemService;
private readonly IFileSystemHistoryItemService _fileSystemHistoryItemService;
private readonly IAuthorizationHelper _authorization;
Expand All @@ -42,19 +41,16 @@ public class FileSystemItemController : ControllerBase
/// <param name="fileSystemHistoryItemService"></param>
/// <param name="authorization"></param>
/// <param name="exporter"></param>
/// <param name="logger"></param>
public FileSystemItemController(
IFileSystemItemService fileSystemItemService,
IFileSystemHistoryItemService fileSystemHistoryItemService,
IAuthorizationHelper authorization,
IXlsExporter exporter,
ILogger<FileSystemItemController> logger)
IXlsExporter exporter)
{
_fileSystemItemService = fileSystemItemService;
_fileSystemHistoryItemService = fileSystemHistoryItemService;
_authorization = authorization;
_exporter = exporter;
_logger = logger;
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
using HSB.DAL.Services;
using HSB.Keycloak;
using HSB.Keycloak.Extensions;
using HSB.Models;

using Swashbuckle.AspNetCore.Annotations;
using Microsoft.Extensions.Caching.Memory;
using HSB.Models.Dashboard;
using HSB.Models.Lists;

namespace HSB.API.Areas.Hsb.Controllers;
namespace HSB.API.Areas.Dashboard.Controllers;

/// <summary>
/// OperatingSystemItemController class, provides endpoints for operating system items.
Expand All @@ -28,7 +29,6 @@ namespace HSB.API.Areas.Hsb.Controllers;
public class OperatingSystemItemController : ControllerBase
{
#region Variables
private readonly ILogger _logger;
private readonly IOperatingSystemItemService _service;
private readonly IAuthorizationHelper _authorization;
private readonly IXlsExporter _exporter;
Expand All @@ -45,19 +45,16 @@ public class OperatingSystemItemController : ControllerBase
/// <param name="memoryCache"></param>
/// <param name="authorization"></param>
/// <param name="exporter"></param>
/// <param name="logger"></param>
public OperatingSystemItemController(
IOperatingSystemItemService service,
IMemoryCache memoryCache,
IAuthorizationHelper authorization,
IXlsExporter exporter,
ILogger<OperatingSystemItemController> logger)
IXlsExporter exporter)
{
_service = service;
_memoryCache = memoryCache;
_authorization = authorization;
_exporter = exporter;
_logger = logger;
}
#endregion

Expand All @@ -69,7 +66,7 @@ public OperatingSystemItemController(
[HttpGet(Name = "GetOperatingSystemItems-Dashboard")]
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(IEnumerable<OperatingSystemItemModel>), (int)HttpStatusCode.OK)]
[SwaggerOperation(Tags = new[] { "Operating System Item" })]
[SwaggerOperation(Tags = ["Operating System Item"])]
// [ResponseCache(VaryByQueryKeys = new[] { "*" }, Location = ResponseCacheLocation.Client, Duration = 60)]
public IActionResult Find()
{
Expand Down Expand Up @@ -112,7 +109,7 @@ public IActionResult Find()
[HttpGet("list", Name = "GetOperatingSystemItemLists-Dashboard")]
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(IEnumerable<OperatingSystemItemListModel>), (int)HttpStatusCode.OK)]
[SwaggerOperation(Tags = new[] { "Operating System Item" })]
[SwaggerOperation(Tags = ["Operating System Item"])]
// [ResponseCache(VaryByQueryKeys = new[] { "*" }, Location = ResponseCacheLocation.Client, Duration = 60)]
public IActionResult FindList()
{
Expand Down Expand Up @@ -155,7 +152,7 @@ public IActionResult FindList()
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(OperatingSystemItemModel), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
[SwaggerOperation(Tags = new[] { "Operating System Item" })]
[SwaggerOperation(Tags = ["Operating System Item"])]
public IActionResult GetForId(int id)
{
var isHSB = this.User.HasClientRole(ClientRole.HSB);
Expand Down Expand Up @@ -190,7 +187,7 @@ public IActionResult GetForId(int id)
[Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")]
[ProducesResponseType((int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
[SwaggerOperation(Tags = new[] { "Operating System Item" })]
[SwaggerOperation(Tags = ["Operating System Item"])]
public IActionResult Export(string format, string name = "service-now")
{
if (format == "excel")
Expand Down
18 changes: 7 additions & 11 deletions src/api/Areas/Dashboard/Controllers/OrganizationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
using HSB.DAL.Services;
using HSB.Keycloak;
using HSB.Keycloak.Extensions;
using HSB.Models;

using Swashbuckle.AspNetCore.Annotations;
using Microsoft.Extensions.Caching.Memory;
using HSB.Models.Dashboard;
using HSB.Models.Lists;

namespace HSB.API.Areas.Hsb.Controllers;
namespace HSB.API.Areas.Dashboard.Controllers;

/// <summary>
/// OrganizationController class, provides endpoints for organizations.
Expand All @@ -28,7 +28,6 @@ namespace HSB.API.Areas.Hsb.Controllers;
public class OrganizationController : ControllerBase
{
#region Variables
private readonly ILogger _logger;
private readonly IOrganizationService _service;
private readonly IAuthorizationHelper _authorization;
#endregion
Expand All @@ -39,15 +38,12 @@ public class OrganizationController : ControllerBase
/// </summary>
/// <param name="service"></param>
/// <param name="authorization"></param>
/// <param name="logger"></param>
public OrganizationController(
IOrganizationService service,
IAuthorizationHelper authorization,
ILogger<OrganizationController> logger)
IAuthorizationHelper authorization)
{
_service = service;
_authorization = authorization;
_logger = logger;
}
#endregion

Expand All @@ -60,7 +56,7 @@ public OrganizationController(
[HttpGet(Name = "GetOrganizations-Dashboard")]
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(IEnumerable<OrganizationModel>), (int)HttpStatusCode.OK)]
[SwaggerOperation(Tags = new[] { "Organization" })]
[SwaggerOperation(Tags = ["Organization"])]
public IActionResult Find()
{
var uri = new Uri(this.Request.GetDisplayUrl());
Expand Down Expand Up @@ -93,7 +89,7 @@ public IActionResult Find()
[HttpGet("list", Name = "GetOrganizationLists-Dashboard")]
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(IEnumerable<OrganizationListModel>), (int)HttpStatusCode.OK)]
[SwaggerOperation(Tags = new[] { "Organization" })]
[SwaggerOperation(Tags = ["Organization"])]
public IActionResult FindList()
{
var uri = new Uri(this.Request.GetDisplayUrl());
Expand Down Expand Up @@ -126,7 +122,7 @@ public IActionResult FindList()
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(OrganizationModel), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
[SwaggerOperation(Tags = new[] { "Organization" })]
[SwaggerOperation(Tags = ["Organization"])]
public IActionResult GetForId(int id)
{
var isHSB = this.User.HasClientRole(ClientRole.HSB);
Expand Down
15 changes: 6 additions & 9 deletions src/api/Areas/Dashboard/Controllers/ServerItemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
using HSB.DAL.Services;
using HSB.Keycloak;
using HSB.Keycloak.Extensions;
using HSB.Models;

using Swashbuckle.AspNetCore.Annotations;
using Microsoft.Extensions.Caching.Memory;
using HSB.Models.Dashboard;
using HSB.Models.Lists;

namespace HSB.API.Areas.Hsb.Controllers;
namespace HSB.API.Areas.Dashboard.Controllers;

/// <summary>
/// ServerItemController class, provides endpoints for server items.
Expand All @@ -28,7 +29,6 @@ namespace HSB.API.Areas.Hsb.Controllers;
public class ServerItemController : ControllerBase
{
#region Variables
private readonly ILogger _logger;
private readonly IServerItemService _serverItemService;
private readonly IServerHistoryItemService _serverHistoryItemService;
private readonly IAuthorizationHelper _authorization;
Expand All @@ -47,21 +47,18 @@ public class ServerItemController : ControllerBase
/// <param name="memoryCache"></param>
/// <param name="authorization"></param>
/// <param name="exporter"></param>
/// <param name="logger"></param>
public ServerItemController(
IServerItemService serverItemService,
IServerHistoryItemService serverHistoryItemService,
IMemoryCache memoryCache,
IAuthorizationHelper authorization,
IXlsExporter exporter,
ILogger<ServerItemController> logger)
IXlsExporter exporter)
{
_serverItemService = serverItemService;
_serverHistoryItemService = serverHistoryItemService;
_memoryCache = memoryCache;
_authorization = authorization;
_exporter = exporter;
_logger = logger;
}
#endregion

Expand Down Expand Up @@ -115,7 +112,7 @@ public IActionResult Find()
[HttpGet("list", Name = "GetServerItemLists-Dashboard")]
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(IEnumerable<ServerItemListModel>), (int)HttpStatusCode.OK)]
[SwaggerOperation(Tags = new[] { "Server Item" })]
[SwaggerOperation(Tags = ["Server Item"])]
public IActionResult FindList()
{
var uri = new Uri(this.Request.GetDisplayUrl());
Expand Down Expand Up @@ -158,7 +155,7 @@ public IActionResult FindList()
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(ServerItemModel), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
[SwaggerOperation(Tags = new[] { "Server Item" })]
[SwaggerOperation(Tags = ["Server Item"])]
public IActionResult GetForId(string serviceNowKey, bool includeFileSystemItems = false)
{
var isHSB = this.User.HasClientRole(ClientRole.HSB);
Expand Down
Loading

0 comments on commit 2847382

Please sign in to comment.