Skip to content

Commit

Permalink
devonfw-forge#41: added Result to SessionStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahffm committed Dec 21, 2022
1 parent 5714a7f commit 3972ce7
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Estimation: FunctionComponent<EstimationProps> = ({ id }) => {
const evaluatedTaskExists = findEvaluatedTask();

// averageComplexity value of the current evaluated task
let averageComplexity = findEvaluatedTask()?.complexityAverage;
let averageComplexity = findEvaluatedTask()?.result?.complexityAverage;

let alreadyVoted = false;

Expand Down Expand Up @@ -73,7 +73,7 @@ export const Estimation: FunctionComponent<EstimationProps> = ({ id }) => {
const evaluatedTask = findEvaluatedTask();

if (evaluatedTask) {
let res = { amountOfVotes: 0, complexityAverage: averageComplexity, finalValue: evaluatedTask.finalValue };
let res = { amountOfVotes: 0, complexityAverage: averageComplexity, finalValue: evaluatedTask.result.finalValue };

const url = baseUrl + serviceUrl + id + "/task/status";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export const TaskCard: FunctionComponent<{
});
};

console.log("Average: " + complexityAverage);
console.log("FinalValue: " + finalValue);

const { deleteTask } = useTaskStore();
const requestDeleteTask = async () => {
const url = baseUrl + serviceUrl + parentSession + "/task/" + id;
Expand Down Expand Up @@ -81,12 +84,9 @@ export const TaskCard: FunctionComponent<{
</button>
);
case Status.Ended:

return (

renderFinalValueOnClosedTasks()

);
);
default:
return <></>
}
Expand All @@ -102,10 +102,10 @@ export const TaskCard: FunctionComponent<{
};

const colorStyle = {
color: '#2ADF6C',
color: '#2ADF6C',
fontWeight: 'bold',
};

/*
function UseUpdateFinalValue() {
const [value, setValue] = useState(0);
Expand All @@ -114,11 +114,11 @@ export const TaskCard: FunctionComponent<{
const forceUpdate = UseUpdateFinalValue()
*/
const renderFinalValueOnClosedTasks = () => (

const renderFinalValueOnClosedTasks = () => (
<>
<div style= {colorStyle} >
Rated: {finalValue}
<div style={colorStyle}>
Rated: {finalValue}
</div>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export const TaskView: FunctionComponent<TaskViewProps> = ({ id }) => {
title={item.title}
description={item.description}
url={item.url}
complexityAverage={item.complexityAverage}
finalValue={item.finalValue}
complexityAverage={item.result?.complexityAverage}
finalValue={item.result?.finalValue}
/>
))}
</div>
Expand Down
12 changes: 5 additions & 7 deletions client/app/Components/Features/Session/Tasks/Stores/TaskStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ export const useTaskStore = create<ISessionTaskState>()((set, get) => ({
})
);
},
//sets the averageComplexity value for each task
// sets average complexity of the open task & changes it to evaluated
setAverageComplexity: (taskResultDto: ITaskResultDto) => {
set(
produce((draft: ISessionTaskState) => {
draft.tasks.forEach((task) => {
if (task.id == taskResultDto.id) {
task.complexityAverage = taskResultDto.complexityAverage;
task.result = { amountOfVotes: 0, complexityAverage: taskResultDto.complexityAverage };
// task.result.complexityAverage = taskResultDto.complexityAverage;
task.status = Status.Evaluated;
}
});
Expand All @@ -128,17 +129,14 @@ export const useTaskStore = create<ISessionTaskState>()((set, get) => ({
setFinalComplexity: (finalValue: Number) => {
set(
produce((draft: ISessionTaskState) => {
const evaluatedTask = get().tasks.find((task) => task.status == Status.Evaluated);
draft.tasks.forEach((task) => {
if (task.id == evaluatedTask.id) {
task.finalValue = finalValue;
console.log("finalValue updated: " + task.finalValue);
if (task.status == Status.Evaluated) {
task.result.finalValue = finalValue;
}
});
})
);
},
//returns the task thats currently in evaluation
findEvaluatedTask: () => {
return get().tasks.find((task) => task.status == Status.Evaluated);
},
Expand Down
8 changes: 8 additions & 0 deletions client/app/Interfaces/IResult.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
export interface IResult {
amountOfVotes: Number,
complexityAverage: Number,
finalValue?: Number
}

/*
export interface IVoteResult {
value: Number;
}
Expand All @@ -11,3 +18,4 @@ export interface ITaskResult {
export interface IResult {
results: ITaskResult[],
}
*/
4 changes: 4 additions & 0 deletions client/app/Interfaces/ITask.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Status } from "../Types/Status";
import { IResult } from "./IResult";

export interface IEstimation {
voteBy: String;
Expand All @@ -12,8 +13,11 @@ export interface ITask {
url?: String;
status: Status;
estimations: IEstimation[];
result?: IResult;
/*
complexityAverage?: Number;
finalValue?: Number;
*/
}

export interface ITaskStatusChange {
Expand Down
12 changes: 3 additions & 9 deletions client/pages/session/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ export default function Session({ id, data }: any) {
const { setCurrentTasks } = useTaskStore();
const { setCurrentUsers } = useSessionUserStore();



useEffect(() => {
const { tasks } = data;

setCurrentTasks(tasks);
setCurrentUsers(dummyUsers);

}, [data, dummyUsers]);

// process onUserConnect, onAnotherUserConnect, markTaskAsActive,
Expand Down Expand Up @@ -83,12 +81,8 @@ export default function Session({ id, data }: any) {
let { payload } = parsed as IMessage<ITaskResultDto>;
console.log("TaskFinalValueAdded received.");
console.log(payload);
console.log(" finalval von PAYLOAD ***" + payload.finalValue);

let final = payload.finalValue;
console.log(" finalval von final ***" + final);
setFinalComplexity(final);
// TODO
setFinalComplexity(payload.finalValue);
}
default: {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,8 @@ public async Task<IActionResult> ChangeTaskStatus(long sessionId, [FromBody] Tas

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

// If the status changed to ended, another message is sent that contains the final voting result
if (statusChange.Status == Status.Ended)
else if (statusChange.Status == Status.Ended)
{
var endedTask = modifiedTasks.Find(item => item.Id == statusChange.Id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public async Task<IActionResult> GetSessionStatus(long id)
{
var (isValid, tasks) = await _sessionService.GetStatus(id);

Devon4NetLogger.Debug($"Session is valid: {isValid}");

var statusResult = new StatusDto
{
IsValid = isValid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public static TaskDto ModelToDto(Devon4Net.Application.WebAPI.Implementation.Dom
Description = task.Description,
Url = task.Url,
Status = task.Status,
Estimations = task.Estimations.Select(item => EstimationConverter.ModelToDto(item)).ToList()
Estimations = task.Estimations.Select(item => EstimationConverter.ModelToDto(item)).ToList(),
Result = task.Result
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class TaskDto

public List<EstimationDto> Estimations { get; set; }

public Result? Result { get; set; }

public void Deconstruct(out string id, out string title, out string? description, out string? url, out Status status)
{
id = Id;
Expand All @@ -40,5 +42,17 @@ public void Deconstruct(out string title, out string? description, out string? u
url = Url;
status = Status;
}

/*
public void Deconstruct(out string id, out string title, out string? description, out string? url, out Status status, out Result? result)
{
id = Id;
title = Title;
description = Description;
url = Url;
status = Status;
result = Result;
}
*/
}
}

0 comments on commit 3972ce7

Please sign in to comment.