remove deprecated duplicate feed detection

This commit is contained in:
Athou
2013-11-16 07:40:44 +01:00
parent 97586cd2c8
commit fce9086b27
7 changed files with 0 additions and 214 deletions

View File

@@ -6,15 +6,12 @@ import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.SetJoin;
import javax.persistence.criteria.Subquery;
import javax.persistence.metamodel.SingularAttribute;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
@@ -26,7 +23,6 @@ import com.commafeed.backend.model.FeedSubscription_;
import com.commafeed.backend.model.Feed_;
import com.commafeed.backend.model.User;
import com.commafeed.backend.model.User_;
import com.commafeed.frontend.model.FeedCount;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -107,47 +103,4 @@ public class FeedDAO extends GenericDAO<Feed> {
return q.getResultList();
}
public static enum DuplicateMode {
NORMALIZED_URL(Feed_.normalizedUrlHash), LAST_CONTENT(Feed_.lastContentHash), PUSH_TOPIC(Feed_.pushTopicHash);
private SingularAttribute<Feed, String> path;
private DuplicateMode(SingularAttribute<Feed, String> path) {
this.path = path;
}
public SingularAttribute<Feed, String> getPath() {
return path;
}
}
public List<FeedCount> findDuplicates(DuplicateMode mode, int offset, int limit, long minCount) {
CriteriaQuery<String> query = builder.createQuery(String.class);
Root<Feed> root = query.from(getType());
Path<String> path = root.get(mode.getPath());
Expression<Long> count = builder.count(path);
query.select(path);
query.groupBy(path);
query.having(builder.greaterThan(count, minCount));
TypedQuery<String> q = em.createQuery(query);
limit(q, offset, limit);
List<String> pathValues = q.getResultList();
List<FeedCount> result = Lists.newArrayList();
for (String pathValue : pathValues) {
FeedCount fc = new FeedCount(pathValue);
for (Feed feed : findByField(mode.getPath(), pathValue)) {
Feed f = new Feed();
f.setId(feed.getId());
f.setUrl(feed.getUrl());
fc.getFeeds().add(f);
}
result.add(fc);
}
return result;
}
}

View File

@@ -1,6 +1,5 @@
package com.commafeed.frontend.rest.resources;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -19,14 +18,12 @@ import org.apache.commons.lang.StringUtils;
import com.codahale.metrics.MetricRegistry;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.dao.FeedDAO.DuplicateMode;
import com.commafeed.backend.dao.UserDAO;
import com.commafeed.backend.dao.UserRoleDAO;
import com.commafeed.backend.feeds.FeedRefreshTaskGiver;
import com.commafeed.backend.feeds.FeedRefreshUpdater;
import com.commafeed.backend.feeds.FeedRefreshWorker;
import com.commafeed.backend.model.ApplicationSettings;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserRole;
import com.commafeed.backend.model.UserRole.Role;
@@ -37,13 +34,10 @@ import com.commafeed.backend.services.PasswordEncryptionService;
import com.commafeed.backend.services.UserService;
import com.commafeed.backend.startup.StartupBean;
import com.commafeed.frontend.SecurityCheck;
import com.commafeed.frontend.model.FeedCount;
import com.commafeed.frontend.model.UserModel;
import com.commafeed.frontend.model.request.FeedMergeRequest;
import com.commafeed.frontend.model.request.IDRequest;
import com.commafeed.frontend.rest.PrettyPrint;
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;
@@ -259,36 +253,4 @@ public class AdminREST extends AbstractREST {
map.put("old_entries", cleaner.cleanEntriesOlderThan(days, TimeUnit.DAYS));
return Response.ok(map).build();
}
@Path("/cleanup/findDuplicateFeeds")
@GET
@ApiOperation(value = "Find duplicate feeds")
public Response findDuplicateFeeds(@QueryParam("mode") DuplicateMode mode, @QueryParam("page") int page,
@QueryParam("limit") int limit, @QueryParam("minCount") long minCount) {
List<FeedCount> list = feedDAO.findDuplicates(mode, limit * page, limit, minCount);
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) {
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();
}
}

View File

@@ -1399,53 +1399,6 @@ module.controller('ManageUserCtrl', ['$scope', '$state', '$stateParams', '$dialo
};
}]);
module.controller('ManageDuplicateFeedsCtrl', ['$scope', 'AdminCleanupService', function($scope, AdminCleanupService) {
$scope.limit = 10;
$scope.page = 0;
$scope.minCount = 1;
$scope.mode = 'NORMALIZED_URL';
$scope.mergeData = {};
$scope.refreshData = function() {
AdminCleanupService.findDuplicateFeeds({
mode : $scope.mode,
limit : $scope.limit,
page : $scope.page,
minCount : $scope.minCount
}, function(data) {
$scope.counts = data;
});
};
$scope.autoMerge = function() {
var callback = function() {
alert('done!');
};
for (var i = 0; i < $scope.counts.length; i++) {
var count = $scope.counts[i];
if (count.autoMerge) {
AdminCleanupService.mergeFeeds({
intoFeedId : count.feeds[0].id,
feedIds : _.pluck(count.feeds, 'id')
}, callback);
}
}
};
$scope.focus = function(count) {
$scope.current = count;
$scope.mergeData.intoFeedId = count.feeds[0].id;
$scope.mergeData.feedIds = _.pluck(count.feeds, 'id');
};
$scope.merge = function() {
AdminCleanupService.mergeFeeds($scope.mergeData, function() {
alert('done!');
});
};
}]);
module.controller('SettingsCtrl', ['$scope', '$location', 'SettingsService', 'AnalyticsService', 'ServerService',
function($scope, $location, SettingsService, AnalyticsService, ServerService) {
@@ -1535,9 +1488,6 @@ module.controller('ManageSettingsCtrl', ['$scope', '$location', '$state', 'Admin
$scope.toUsers = function() {
$state.transitionTo('admin.userlist');
};
$scope.toCleanup = function() {
$state.transitionTo('admin.duplicate_feeds');
};
}]);
module.controller('HelpController', ['$scope', 'CategoryService', 'AnalyticsService', 'ServerService',

View File

@@ -95,11 +95,6 @@ app.config(['$routeProvider', '$stateProvider', '$urlRouterProvider', '$httpProv
templateUrl : 'templates/admin.useredit.html',
controller : 'ManageUserCtrl'
});
$stateProvider.state('admin.duplicate_feeds', {
url : '/feeds/duplicates',
templateUrl : 'templates/admin.duplicate_feeds.html',
controller : 'ManageDuplicateFeedsCtrl'
});
$stateProvider.state('admin.settings', {
url : '/settings',
templateUrl : 'templates/admin.settings.html',

View File

@@ -315,26 +315,6 @@ module.factory('AdminMetricsService', ['$resource', function($resource) {
return res;
}]);
module.factory('AdminCleanupService', ['$resource', function($resource) {
var actions = {
findDuplicateFeeds : {
method : 'GET',
isArray : true,
params : {
_method : 'findDuplicateFeeds'
}
},
mergeFeeds : {
method : 'POST',
params : {
_method : 'merge'
}
}
};
var res = $resource('rest/admin/cleanup/:_method', {}, actions);
return res;
}]);
module.factory('ServerService', ['$resource', function($resource) {
var res = $resource('rest/server/get');
return res;

View File

@@ -1,50 +0,0 @@
<div class="row">
<div>
Limit <input type="number" ng-model="limit" />
Page <input type="number" ng-model="page" />
Min. count <input type="number" ng-model="minCount" />
</div>
<div>
Mode
<select ng-model="mode">
<option value="NORMALIZED_URL">Normalized URLs</option>
<option value="LAST_CONTENT">Last content</option>
<option value="PUSH_TOPIC">Pubsubhubbub topic URL</option>
</select>
<input type="button" class="btn" ng-click="refreshData()" value="Refresh" />
<input type="button" class="btn" ng-click="autoMerge()" value="Auto merge selected" />
</div>
<table class="table table-condensed table-hover" ng-if="counts">
<thead>
<tr>
<th></th>
<th>url</th>
<th>count</h>
</tr>
</thead>
<tbody>
<tr ng-repeat="count in counts" ng-click="focus(count)" class="pointer">
<td><input type="checkbox" ng-model="count.autoMerge" /> </td>
<td>{{count.feeds[0].url}}</td>
<td>{{count.feeds.length}}</td>
</tr>
</tbody>
</table>
<div ng-if="current">
<div>
Merge
<select ng-model="mergeData.feedIds" size="30" multiple="multiple" class="input-block-level"
ng-options="feed.id as feed.url for feed in current.feeds">
</select>
</div>
<div>
Into
<select ng-model="mergeData.intoFeedId" ng-options="feed.id as feed.url for feed in current.feeds" class="input-block-level">
</select>
</div>
<input type="button" class="btn" ng-click="merge()" value="Merge" />
</div>
</div>

View File

@@ -5,10 +5,6 @@
<small>
<a ng-click="toUsers()" class="pointer">Manage users</a>
</small>
-
<small>
<a ng-click="toCleanup()" class="pointer">Cleanup feeds</a>
</small>
</h1>
</div>