-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
@JsonProperty("created_at") | ||
public String createdAt; | ||
public Instant createdAt; // Changed the type to Instant |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
server/src/main/java/edu/sjsu/moth/server/controller/StatusController.java
Outdated
Show resolved
Hide resolved
@@ -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() |
There was a problem hiding this comment.
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.) |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
No description provided.