Skip to content

Sprint 8 solution time and duration - #4

Merged
AleksOBM merged 3 commits into
mainfrom
sprint_8-solution-time-and-duration
Nov 11, 2025
Merged

Sprint 8 solution time and duration#4
AleksOBM merged 3 commits into
mainfrom
sprint_8-solution-time-and-duration

Conversation

@AleksOBM

@AleksOBM AleksOBM commented Nov 9, 2025

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/data/Task.java Outdated
protected Duration duration = Duration.ZERO;

/// Дата и время завершения задачи
protected LocalDateTime endTime;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

эта переменная нужна только в классе Epic
+
там ей нужны обычные геттер и сеттер

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

готово

Comment thread src/data/Task.java Outdated
/// Внесение времени начала выполнения
public void setStartTime(LocalDateTime startTime) {
this.startTime = startTime;
if (startTime != null) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

этот код нужно перенести в метод getEndTime()

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

готово

Comment thread src/manager/FileBackedTaskManager.java Outdated

/// Параметры CSV файла
private static final String TABLE_HEADER = "id,type,name,status,description,epic";
private static final String TABLE_HEADER = "start, end, duration, id,type,name,status,description,epic";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

думаю новые поля нужно добавить в конец, а не начало

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

готово
epicId все таки оставил в конце, для читаемости, т.к. там будут пустые ячейки

Comment thread src/manager/InMemoryTaskManager.java Outdated
}

return oldEpic;
if (newEpic.getStartTime() != null) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

время в эпике так же обновляется через подзадачи, поэтому этот метод не меняется

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

готово
👍

Comment thread src/manager/InMemoryTaskManager.java Outdated
}

/// Проверка пересечений времени
private boolean isFoundIntersections(Task taskObject) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

первым делом стоит проверить заполнены ли атрибуты времени у taskObject, если нет, можно сразу ответить false и не тратить ресурсы

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

готово

private boolean isFoundIntersections(Task taskObject) {
Task savedTask = getWithoutHistory(taskObject.getId());
Task testTask = taskObject.getCopy();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

а для чего нужно перекладывать время из taskObject в testTask? почему нельзя передать в findIntersections() сразу taskObject?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

нашел еще одну ошибку, что нельзя проапдейтить нулевое время
ошибку исправил, но перекладывание полностью устранить не удалось

Comment thread src/manager/InMemoryTaskManager.java Outdated
historyManager.remove(subtaskId);
}
idToSubtask.clear();
prioritizedTasks.removeIf(task -> task.getType() == Type.EPIC);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

эпиков там нет, удалить нужно все подзадачи, только лучше это делать в цикле совместно с удалением из истории

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

готово

Comment thread src/manager/InMemoryTaskManager.java Outdated
updateEpicsStatus(epic.getId());
clearEpicTime(epic);
}
prioritizedTasks.removeIf(task -> task.getType() == Type.SUBTASK);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

лучше удалить в одном цикле с удалением из истории

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

готово

Comment thread src/manager/InMemoryTaskManager.java Outdated

/// Обновление продолжительности эпика
protected void updateEpicTime(Epic epic) {
if (epic.getId() == null || epic.getStartTime() == null) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

отсутствие времени не повод прерывать метод, например у вновь созданного эпика он всегда null

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

готово

Comment thread src/manager/InMemoryTaskManager.java Outdated

if (firstSubtask.equals(lastSubtask)) {
clearEpicTime(epic);
epic.setStartTime(firstSubtask.getStartTime());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

еще нужно присвоить продолжительность и endTime

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

заменил этот кусок полностью

@AleksOBM
AleksOBM merged commit a5ba512 into main Nov 11, 2025
1 check passed
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