Skip to content

Commit

Permalink
devonfw-forge#41: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahffm committed Dec 5, 2022
1 parent 50e5dcf commit 74cd6c5
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 13 deletions.
6 changes: 6 additions & 0 deletions client/app/Interfaces/ITaskResultDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface ITaskResultDto {
taskId: String;
amountOfVotes: Number;
complexityAverage: Number;
finalValue?: Number;
}
2 changes: 1 addition & 1 deletion client/app/Types/Type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export enum Type {
TaskStatusModified = 1,
TaskDeleted = 2,
EstimationAdded = 3,
TaskResultAdded = 4
TaskAverageAdded = 4
}
8 changes: 4 additions & 4 deletions client/pages/session/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { IWebSocketMessage } from "../../app/Interfaces/IWebSocketMessage";
import { Type } from "../../app/Types/Type";
import { dummyUsers } from "../../app/Components/Globals/DummyData";
import { IEstimationDto } from "../../app/Interfaces/IEstimationDto";
import { ITaskResultDto } from "../../app/Interfaces/ITaskResultDto";

export default function Session({ id, data }: any) {
const { setCurrentTasks } = useTaskStore();
Expand Down Expand Up @@ -74,11 +75,10 @@ export default function Session({ id, data }: any) {

break;
}
case Type.TaskResultAdded: {
// let { payload } = parsed as IMessage<ITaskResultDto>;

case Type.TaskAverageAdded: {
let { payload } = parsed as IMessage<ITaskResultDto>;
console.log("TaskResultAdded received.");
// console.log(payload);
console.log(payload);
}
default: {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,11 @@ public async Task<IActionResult> ChangeTaskStatus(long sessionId, [FromBody] Tas
var taskResult = new TaskResultDto()
{
Id = statusChange.Id,
Result = evaluatedTask.Result
AmountOfVotes = evaluatedTask.Result.AmountOfVotes,
ComplexityAverage = evaluatedTask.Result.ComplexityAverage,
};

await _webSocketHandler.Send(new Message<TaskResultDto> { Type = MessageType.TaskResultAdded, Payload = taskResult }, sessionId);
await _webSocketHandler.Send(new Message<TaskResultDto> { Type = MessageType.TaskAverageAdded, Payload = taskResult }, sessionId);
}

return Ok(modifiedTasks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ public class TaskResultDto
{
public string Id { get; set; }

public Result Result { get; set; }
public int AmountOfVotes { get; set; }

public float ComplexityAverage { get; set; }

public int? FinalValue { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public enum MessageType
TaskStatusModified,
TaskDeleted,
EstimationAdded,
TaskResultAdded
TaskAverageAdded
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public async Task<ResultCreateSessionDto> CreateSession(SessionDto sessionDto)
Users = new List<Domain.Entities.User>()
});

return new ResultCreateSessionDto{
return new ResultCreateSessionDto
{
Id = (long)result.RawValue
};
}
Expand Down Expand Up @@ -288,7 +289,7 @@ private string generateInviteToken()
return (false, new List<TaskStatusChangeDto>());
}

// calculate the result if the task is evaluated
// calculate the voting result if the task is evaluated
Result result = new Result();
if (status == Status.Evaluated)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ public partial class Result
{
public int AmountOfVotes { get; set; }

public double ComplexityAverage { get; set; }
public float ComplexityAverage { get; set; }

public int? FinalValue { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Result calculateResult()
var taskResult = new Result()
{
AmountOfVotes = Estimations.Count,
ComplexityAverage = Estimations.Select(est => est.Complexity).Average()
ComplexityAverage = (float)Estimations.Select(est => est.Complexity).Average()
};

Result = taskResult;
Expand Down

0 comments on commit 74cd6c5

Please sign in to comment.