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 API with queue history in CSV #166

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

piotrwasko
Copy link

@piotrwasko piotrwasko commented Oct 15, 2021

PR resolves #165

@@ -86,4 +89,13 @@
@PathVariable("queueId") String queueId) {
return ResponseEntity.ok(queueService.getQueueEvents(queueId));
}

@GetMapping(path = "/queue/{queueId}/history", produces = "text/csv")
@ResponseBody
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need @ResponseBody?


@GetMapping(path = "/queue/{queueId}/history", produces = "text/csv")
@ResponseBody
public QueueEventsCsvResponse getQueueHistoryCSV(
Copy link
Collaborator

Choose a reason for hiding this comment

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

rename function to getQueueEventsCsv and make the path "/queue/{queueId}/eventsCsv"

import java.nio.charset.StandardCharsets;

@Component
public class QueueEventsCsvResponseConverter extends AbstractHttpMessageConverter<QueueEventsCsvResponse> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's write a converter for QueueEventsResponse and remove QueueEventsCsvResponse and getQueueEventsInCsv service function.

As per this, it will use the media type to determine the converter, this should work. Can you try?

Copy link
Author

@piotrwasko piotrwasko Oct 17, 2021

Choose a reason for hiding this comment

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

If we are going to use Accept header to decide on the response content, then maybe just one endpoint would be enough?

  • GET /queue/{queueId}/events with Accept: application/json would return the events in JSON,
  • GET /queue/{queueId}/events with Accept: text/csvwould return a CSV

What do you think?

Copy link
Author

Choose a reason for hiding this comment

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

QueueEventsResponse does not include queue name. I wanted to use it to make the filename more accessible. Do you think a generic name like history.csv is ok?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Using the Accept header if that works would be the best way, in my opinion.

I wanted to use it to make the filename more accessible.

Yeah, that would be desirable. Can you try adding the queue Id and name to QueueEventsResponse? In case that's difficult, we can fallback to a generic name.

Copy link
Collaborator

@daltonfury42 daltonfury42 left a comment

Choose a reason for hiding this comment

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

Thanks for this, and happy hacking.

@daltonfury42 daltonfury42 enabled auto-merge (squash) October 17, 2021 19:49
Copy link
Collaborator

@daltonfury42 daltonfury42 left a comment

Choose a reason for hiding this comment

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

@piotrwasko Can you fix the tests? Looks like you are missing some imports

@meetcngh-sopho
Copy link

Is this pr right ?

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.

Add API to export queue events as CSV
3 participants