Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add findByCurrentStatus method with sort parameter to order by contributionDeadline #468

Merged
merged 12 commits into from
Dec 23, 2021

Conversation

jbern0rd
Copy link
Contributor

Draft PR for comments
To be complete, this feature would merit a basic integration test to check the mongodb query is correct and returns tasks in the expected order.

@jbern0rd jbern0rd requested a review from a team November 25, 2021 15:30
@@ -40,6 +41,9 @@
@Query("{ 'currentStatus': {$in: ?0} }")
List<Task> findByCurrentStatus(List<TaskStatus> statuses);

@Query("{ 'currentStatus'; {$in: ?0} }")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@Query("{ 'currentStatus'; {$in: ?0} }")
@Query("{ 'currentStatus': {$in: ?0} }")

@jbern0rd jbern0rd force-pushed the feature/order-tasks-by-contribution-deadline branch from 8360653 to 7bec98e Compare December 10, 2021 16:45
@jbern0rd jbern0rd marked this pull request as ready for review December 13, 2021 11:06
* the main thread, since deals can have
* a large number of tasks (BoT).
*/
@Async
@EventListener(ApplicationReadyEvent.class)
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@zguesmi zguesmi left a comment

Choose a reason for hiding this comment

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

Well done 👏

Copy link
Member

@jeremyjams jeremyjams left a comment

Choose a reason for hiding this comment

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

Great, thank you for your tests!

@mcornaton mcornaton self-requested a review December 13, 2021 16:09
Copy link
Contributor

@mcornaton mcornaton left a comment

Choose a reason for hiding this comment

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

Thanks!

tasks.add(task);
}
taskRepository.saveAll(tasks);
tasks.sort(Comparator.comparing(Task::getCurrentStatus, Comparator.reverseOrder())
Copy link
Member

Choose a reason for hiding this comment

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

I think it is interesting/clearer to add at least 1 test where expected task list is explicitly defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be alright to have a simple test with fixed data and a fuzzy one with randomization to try different combinations ?

Copy link
Member

Choose a reason for hiding this comment

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

That would be perfect, having both benefits!

src/test/java/com/iexec/core/task/TaskRepositoryTest.java Outdated Show resolved Hide resolved
import static com.iexec.core.task.TaskStatus.RUNNING;
import static com.iexec.core.task.TaskTestsUtils.getStubTask;

@DataMongoTest
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure we want Spring tests in our unit tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are specific tests which only create beans for entities and repositories. The beans annotated with @components and @Services are not created.
The new tests specifically target and validate the data model which should be validated as early as possible.
There is a valid discussion on the topic and we decided to start this way and maybe to refactor later.

@jbern0rd jbern0rd merged commit f77c260 into develop Dec 23, 2021
@jbern0rd jbern0rd deleted the feature/order-tasks-by-contribution-deadline branch December 23, 2021 08:23
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.

None yet

4 participants