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

Adds the endpoint to obtain a product list report of the chosen products by id #460

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

k31kur0n0
Copy link
Member

No description provided.

@k31kur0n0 k31kur0n0 self-assigned this Mar 10, 2023
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@belluccifranco
Copy link
Member

belluccifranco commented Mar 10, 2023

The sonar analysis is failed, no test coverage 😞

@@ -139,6 +143,18 @@ public void getListaDePrecios(
}
}

@GetMapping("/productos/reporte")
public ResponseEntity<byte[]> getListaProductosSeleccionados(
Copy link
Member

Choose a reason for hiding this comment

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

The response should be sent by email

Copy link
Member Author

Choose a reason for hiding this comment

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

The use case doesn't require the response to be send by email, the requirement is obtain a report of the chosen products the same way that others like Factura and Pedidos do, the email one it's beacause usualy whitout a product selection the list is to big and the request take to long

Copy link
Member

Choose a reason for hiding this comment

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

What if the user selects X (a very big number) products and sends the request? It's gonna crush. We need to cover all possible scenarios

Copy link
Member Author

Choose a reason for hiding this comment

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

Happens that the access to the business email account it's only to very few people, and the new feature it's to vendedor use as "Presupuesto". Now I notice a problem, to use this as a vendedor we have to let it access to the product administration list, then the real solution it's to have a real "Presupuesto" report, this do not solve the original problem and carry a new one.

@GetMapping("/productos/reporte")
public ResponseEntity<byte[]> getListaProductosSeleccionados(
@RequestParam long[] idProducto) {
HttpHeaders headers = new HttpHeaders();
Copy link
Member

Choose a reason for hiding this comment

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

Could use "var" instead

headers.setContentType(MediaType.APPLICATION_PDF);
headers.add("content-disposition", "inline; filename=ProductList.pdf");
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
byte[] reportePDF =
Copy link
Member

Choose a reason for hiding this comment

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

Could use "var" instead, and all in one line

public byte[] getListaDePreciosEnPdf(long[] idProductos) {
var productos = new ArrayList<Producto>();
for (long idProducto : idProductos) {
productos.add(this.getProductoNoEliminadoPorId(idProducto));
Copy link
Member

Choose a reason for hiding this comment

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

This is very inefficient. The query should be something like SELECT xxxx FROM xxxx WHERE IN .....

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agregar a la funcionalidad de reporte de productos, la posibilidad de emitir uno de un grupo seleccionado
2 participants