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

View trending statuses #108

Merged
merged 3 commits into from
Aug 2, 2023
Merged

View trending statuses #108

merged 3 commits into from
Aug 2, 2023

Conversation

andremanzo1
Copy link
Collaborator

No description provided.

@JsonProperty("created_at")
public String createdAt;
public Instant createdAt; // Changed the type to Instant
Copy link
Contributor

Choose a reason for hiding this comment

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

we want to keep this a string. you can add a utility method to convert to an instance in the Util class. there is already one there for now().

@@ -113,6 +115,25 @@ Mono<ResponseEntity<List<Status>>> getApiV1AccountsStatuses(@PathVariable String
limit))
.map(ResponseEntity::ok);
}
@GetMapping("/api/v1/trends/statuses")
Copy link
Contributor

Choose a reason for hiding this comment

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

put a link to the spec you are using. there is a limit and skip parameter that you can easily put in here.

@@ -113,6 +115,25 @@ Mono<ResponseEntity<List<Status>>> getApiV1AccountsStatuses(@PathVariable String
limit))
.map(ResponseEntity::ok);
}
@GetMapping("/api/v1/trends/statuses")
Mono<ResponseEntity<List<Status>>> getApiV1TrendingStatuses() {
return statusService.getAllStatuses()
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use skip() and take() before the collectList to do the skipping and taking

return statusService.getAllStatuses()
.collectList()
.map(statusList -> {
// Sort the statuses based on some criteria (e.g., timestamp, likes, etc.)
Copy link
Contributor

Choose a reason for hiding this comment

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

if you do the skip and take you can just return the list

@@ -58,4 +82,10 @@ public Mono<List<Status>> getStatusesForId(String username, String max_id, Strin
int count = limit == null || limit > 40 || limit < 1 ? 40 : limit;
return statusRepository.findAll(predicate, Sort.by(Sort.Direction.DESC, "id")).take(count).collectList();
}
public Flux<Status> getAllStatuses() {
return statusRepository.findAll();
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think we want findAll, you should at list pass skip and limit.

@andremanzo1 andremanzo1 merged commit 4ebb4b1 into main Aug 2, 2023
1 check passed
@andremanzo1 andremanzo1 deleted the main.errorhandler branch August 2, 2023 23:26
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