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