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

#103 - adding pagination #104

Draft
wants to merge 15 commits into
base: development
Choose a base branch
from

Conversation

pveeckhout
Copy link
Contributor

closes #103

@pveeckhout pveeckhout added the enhancement New feature or request label Aug 29, 2023
@pveeckhout pveeckhout self-assigned this Aug 29, 2023
@pveeckhout pveeckhout linked an issue Aug 29, 2023 that may be closed by this pull request
@pveeckhout pveeckhout marked this pull request as draft September 1, 2023 08:25
@pveeckhout pveeckhout marked this pull request as ready for review September 4, 2023 15:20
return taskExecutor;
@Bean(name = "explorationForkJoinPool")
public ForkJoinPool forkJoinPool() {
return new ForkJoinPool(50); // todo set from config
Copy link
Contributor

Choose a reason for hiding this comment

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

Magic number and a TODO tag, should we not have these summarised in some issue? Maybe deal with it all under one issue?

Ideally, should be configurable.

import io.edpn.backend.trade.application.dto.persistence.entity.PersistencePageInfo;
import io.edpn.backend.trade.application.dto.persistence.entity.mapper.PersistencePageInfoMapper;

public class MybatisPageInfoMapper implements PersistencePageInfoMapper {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing in this class is specific to Trade, but could be useful for other modules... perhaps we should consider adding a "common" module for things like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this would mean breaking changes for all modules, one change in will ripple to all. the modules are not versioned independently in the modulith

Copy link
Contributor

Choose a reason for hiding this comment

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

this would mean breaking changes for all modules, one change in will ripple to all. the modules are not versioned independently in the modulith

Well, is there something keeping us from versioning them independently?

require_odyssey,
fleet_carrier
FROM filtered_lcv
WHERE 1 = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

We still have WHERE 1=1 - not critical though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here it is needed, all following AND clauses can be filtered out and we need one initial where otherwise there is a syntax error


private PageFilter.PageFilterBuilder getDefaultFilterBuilder() {
return PageFilter.builder()
.size(20) //TODO get from config
Copy link
Contributor

Choose a reason for hiding this comment

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

Magic number again that should be configurable as a defaultPageSize etc.

@@ -228,7 +230,7 @@ public RequestMissingSystemCoordinatesService requestMissingSystemCoordinatesUse
CreateSystemCoordinateRequestPort createSystemCoordinateRequestPort,
SendKafkaMessagePort sendKafkaMessagePort,
@Qualifier("tradeRetryTemplate") RetryTemplate retryTemplate,
@Qualifier("tradeThreadPoolTaskExecutor") Executor executor,
@Qualifier("tradeForkJoinPool") Executor executor,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I cant comment the line apparently, line 246 for tradeRequestMissingStationRequireOdysseyUseCase bean has an invalid executor qualifier now. Revise

Long minSupply,
Long minDemand) implements LocateCommodityFilterDto {
Long minDemand,
RestPageFilterDto page
Copy link
Collaborator

Choose a reason for hiding this comment

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

This currently does not work. Im not sure if we can fix this with @Jacksonized. But with a corrected http request this throws mapping errors. Consider flattening and converting to a domain object via mapper, or investigate a way to make this work with a get request


@GetMapping("/locate-commodity/filter")
public List<RestLocateCommodityDto> locateCommodityWithFilters(RestLocateCommodityFilterDto locateCommodityFilterDto){
@ApiResponses({
Copy link
Collaborator

@Daniel-J-Mason Daniel-J-Mason Sep 14, 2023

Choose a reason for hiding this comment

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

This endpoint does not work. [] do not encode properly in tomcat 8.5+, http encrypts [ = %5B and ] = %5D
Find a way to fix if we are going to maintain this structure for the endpoint. This is potentially a problem on the swagger side, but requires a bit more digging

Copy link
Contributor

@jakaarl jakaarl left a comment

Choose a reason for hiding this comment

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

I'm a bit at a loss about where enums, records and such can or cannot be used and why. Doesn't seem very consistent to me. 😕

@AllArgsConstructor
@NoArgsConstructor
@Builder
@EqualsAndHashCode
Copy link
Contributor

Choose a reason for hiding this comment

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

As much as I hate writing boilerplate, this sort of ADD (not attention deficit disorder, Annotation Driven Development!) makes me cringe, too. IIRC, we have some limitations wrt. using records, but do they apply here?

OFFSET (#{page.size} * #{page.page})
</if>
</script>
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

I honestly don't get why annotations with embedded scripting generating SQL would be a good idea. Personally, would choose a type-safe programmatic approach any given day. JOOQ or QueryDSL or something.

Please, at least tell me the validity and correctness of the scripts are checked at compile time!

Copy link
Contributor

Choose a reason for hiding this comment

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

Disclaimer: I don't have any prior experience on MyBatis. In fact, been trying to read up on it, but their own documentation seems a bit... thin. Could use a few pointers or a reading list.


private static LandingPadSize getShipSize(LocateCommodityFilterDto locateCommodityFilterDto) {
return Optional.ofNullable(locateCommodityFilterDto.shipSize())
.map(LandingPadSize::valueOf)
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the enum is being converted back and forth - I'm guessing enum is not an option for DTOs because reasons?

@ToString
@AllArgsConstructor
@Builder
public class PageInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

Guessing this could be a record, since PagedResult right next door is...

Double yCoordinate();


Double zCoordinate();
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW do X, Y and Z coordinates make much sense independently? If not, shouldn't we have a Coordinates object instead?

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

@ExtendWith(MockitoExtension.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like MockitoExtension isn't really used here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 🚧 In Progress
Development

Successfully merging this pull request may close these issues.

add pagination to /locate-commodity/filter endpoint
4 participants