speed up mark all as read

This commit is contained in:
Athou
2013-04-06 07:08:52 +02:00
parent a130d7937d
commit 56e3f36262

View File

@@ -172,32 +172,40 @@ public class EntriesREST extends AbstractREST {
FeedEntry entry = feedEntryService.findById(Long.valueOf(id)); FeedEntry entry = feedEntryService.findById(Long.valueOf(id));
markEntry(entry, read); markEntry(entry, read);
} else if (type == Type.feed) { } else if (type == Type.feed) {
Feed feed = feedSubscriptionService.findById(Long.valueOf(id)) if (read) {
.getFeed(); Feed feed = feedSubscriptionService.findById(Long.valueOf(id))
List<FeedEntryWithStatus> entries = feedEntryService.getEntries( .getFeed();
feed, getUser(), false); List<FeedEntryWithStatus> entries = feedEntryService
for (FeedEntryWithStatus entry : entries) { .getEntries(feed, getUser(), true);
markEntry(entry, read); for (FeedEntryWithStatus entry : entries) {
markEntry(entry, read);
}
} else {
return Response.status(Status.FORBIDDEN)
.entity("Operation not supported").build();
} }
} else if (type == Type.category) { } else if (type == Type.category) {
List<FeedEntryWithStatus> entries = null; if (read) {
List<FeedEntryWithStatus> entries = null;
if (ALL.equals(id)) { if (ALL.equals(id)) {
entries = feedEntryService.getEntries(getUser(), false); entries = feedEntryService.getEntries(getUser(), true);
} else {
FeedCategory feedCategory = feedCategoryService.findById(
getUser(), Long.valueOf(id));
List<FeedCategory> childrenCategories = feedCategoryService
.findAllChildrenCategories(getUser(), feedCategory);
entries = feedEntryService.getEntries(childrenCategories,
getUser(), true);
}
for (FeedEntryWithStatus entry : entries) {
markEntry(entry, read);
}
} else { } else {
FeedCategory feedCategory = feedCategoryService.findById( return Response.status(Status.FORBIDDEN)
getUser(), Long.valueOf(id)); .entity("Operation not supported").build();
List<FeedCategory> childrenCategories = feedCategoryService
.findAllChildrenCategories(getUser(), feedCategory);
entries = feedEntryService.getEntries(childrenCategories,
getUser(), false);
} }
for (FeedEntryWithStatus entry : entries) {
markEntry(entry, true);
}
} }
return Response.ok(Status.OK).build(); return Response.ok(Status.OK).build();
} }