mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
interface for deleting duplicates
This commit is contained in:
@@ -21,6 +21,7 @@ import com.commafeed.backend.DatabaseCleaner;
|
||||
import com.commafeed.backend.MetricsBean;
|
||||
import com.commafeed.backend.StartupBean;
|
||||
import com.commafeed.backend.dao.FeedDAO;
|
||||
import com.commafeed.backend.dao.FeedDAO.FeedCount;
|
||||
import com.commafeed.backend.dao.UserDAO;
|
||||
import com.commafeed.backend.dao.UserRoleDAO;
|
||||
import com.commafeed.backend.feeds.FeedRefreshTaskGiver;
|
||||
@@ -38,8 +39,8 @@ import com.commafeed.frontend.SecurityCheck;
|
||||
import com.commafeed.frontend.model.UserModel;
|
||||
import com.commafeed.frontend.model.request.FeedMergeRequest;
|
||||
import com.commafeed.frontend.model.request.IDRequest;
|
||||
import com.google.api.client.util.Lists;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.wordnik.swagger.annotations.Api;
|
||||
@@ -268,17 +269,36 @@ public class AdminREST extends AbstractResourceREST {
|
||||
return Response.ok(map).build();
|
||||
}
|
||||
|
||||
@Path("/cleanup/findDuplicateFeeds")
|
||||
@GET
|
||||
@ApiOperation(value = "Find duplicate feeds")
|
||||
public Response findDuplicateFeeds(@QueryParam("page") int page,
|
||||
@QueryParam("limit") int limit) {
|
||||
List<FeedCount> list = feedDAO.findDuplicates(limit * page, limit);
|
||||
return Response.ok(list).build();
|
||||
}
|
||||
|
||||
@Path("/cleanup/merge")
|
||||
@POST
|
||||
@ApiOperation(value = "Merge feeds", notes = "Merge feeds together")
|
||||
public Response mergeFeeds(@ApiParam(required = true) FeedMergeRequest request) {
|
||||
public Response mergeFeeds(
|
||||
@ApiParam(required = true) FeedMergeRequest request) {
|
||||
Feed into = feedDAO.findById(request.getIntoFeedId());
|
||||
if (into == null) {
|
||||
return Response.status(Status.BAD_REQUEST)
|
||||
.entity("'into feed' not found").build();
|
||||
}
|
||||
|
||||
List<Feed> feeds = Lists.newArrayList();
|
||||
for (Long feedId : request.getFeedIds()) {
|
||||
Feed feed = feedDAO.findById(feedId);
|
||||
feeds.add(feed);
|
||||
}
|
||||
|
||||
if (feeds.isEmpty()) {
|
||||
return Response.status(Status.BAD_REQUEST)
|
||||
.entity("'from feeds' empty").build();
|
||||
}
|
||||
|
||||
cleaner.mergeFeeds(into, feeds);
|
||||
return Response.ok().build();
|
||||
|
||||
Reference in New Issue
Block a user