Skip to content

Rate and block workers (Patricio)#4

Open
gonzalo-bl wants to merge 1 commit intomainfrom
rate-and-block-workers
Open

Rate and block workers (Patricio)#4
gonzalo-bl wants to merge 1 commit intomainfrom
rate-and-block-workers

Conversation

@gonzalo-bl
Copy link
Contributor

@gonzalo-bl gonzalo-bl commented Mar 9, 2026

Feature: Rate & Block Workers

Healthcare facilities using our shift management platform have requested functionality to:

  • Rate workers after each completed shift.
  • Block workers they no longer wish to work with.

This pull request introduces new endpoints to enable those actions.

Acceptance Criteria

✅ A facility can submit a rating (1–5 stars, optional comment) for a worker after a shift.

✅ A facility can block a worker from being assigned to future shifts.

✅ Blocked workers must not be assignable to future shifts at the blocking facility.

@gonzalo-bl gonzalo-bl changed the title feature changes Rate and block workers (Patricio) Mar 9, 2026
FacilityId = table.Column<int>(nullable: false),
WorkerId = table.Column<int>(nullable: false),
Score = table.Column<int>(nullable: false)
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a missing property to add an optional comment (nullable).


[HttpGet]
public IActionResult GetFacilities() => Ok(_dbContext.Facilities.ToList());
public FacilitiesController(AppDbContext dbContext, RateWorkerHandler rateWorkerHandler, BlockWorkerHandler blockWorkerHandler)
Copy link

@plussenhoff plussenhoff Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not expose a dbContext here. It should live within a Repository class.

}

[HttpGet("facilities/list")]
public async Task<IActionResult> GetFacilities([FromBody] RateWorkerRequest request)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GET methods should not use Body according to conventions.

_blockWorkerHandler = blockWorkerHandler;
}

[HttpGet("facilities/list")]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use relative paths, otherwise we could end up having duplicate segments.

[HttpGet("facilities/list")]
public async Task<IActionResult> GetFacilities([FromBody] RateWorkerRequest request)
{
return await _dbContext.Facilities.ToListAsync();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbContext should not be exposed here. There should be a handler and a repository containing the dbContext and queries. We should not return full domain entities, use DTOs instead and return a proper status code (Ok, BadRequest, NotFound, etc).


[HttpGet]
public IActionResult GetFacilities() => Ok(_dbContext.Facilities.ToList());
public FacilitiesController(AppDbContext dbContext, RateWorkerHandler rateWorkerHandler, BlockWorkerHandler blockWorkerHandler)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this class is not following dependency inversion principle. We should use abstractions (interfaces) instead of implementations. Delegate instance creation to the framework by registering dependencies in the DI container to the proper lifetime.

{
try
{
_workerRepository.BlockWorker(request.WorkerId, request.FacilityId);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling a blocking operation like requests to DB, files, other API synchronously will block the current thread and can lead to thread pool starvation. Add await for this kind of operations as a good practice to release the thread so it can.

}
catch (Exception e)
{
return new JsonResult(new { error = e.Message });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a log for this exception and we could return a general message to the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants