Skip to content

Commit

Permalink
Only show internal searches in search search history
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Jan 25, 2017
1 parent 2e466b2 commit 9cc22bf
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion nzbhydra/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def get_search_requests(page=0, limit=100, sortModel=None, type=None, filterMode
((Search.identifier_value == MovieIdCache.tmdb) & (Search.identifier_key == "tmdbid"))))

if type is not None and type != "All":
query = query.where(Search.internal) if type == "Internal" else query.where(~Search.internal)
query = query.where(Search.internal) if type.lower() == "internal" else query.where(~Search.internal)
if filterModel:
for column, filter in filterModel.items():
where = column
Expand Down
12 changes: 1 addition & 11 deletions nzbhydra/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,16 +980,6 @@ def internalapi_getnzb_downloads(args):
return jsonify(get_nzb_downloads(page=args["page"], limit=args["limit"], type=args["type"]))


internalapi__getsearchrequests_args = {
"page": fields.Integer(missing=0),
"limit": fields.Integer(missing=500),
"type": fields.String(missing=None),
"sortModel": fields.Nested({
"colId": fields.String(),
"sort": fields.String()
}, many=True)
}

class SortModelSchema(Schema):
colId = fields.String()
sort = fields.String()
Expand All @@ -1009,7 +999,7 @@ def internalapi_search_requests(args):
if not "sortModel" in args.keys() or args["sortModel"] is None:
args["sortModel"] = []
filterModel = request.json["filterModel"] if "filterModel" in request.json.keys() else None
return jsonify(get_search_requests(page=args["page"], limit=args["limit"], sortModel=args["sortModel"], filterModel=filterModel))
return jsonify(get_search_requests(page=args["page"], limit=args["limit"], sortModel=args["sortModel"], type=args["type"], filterModel=filterModel))


internalapi__redirect_rid_args = {
Expand Down
18 changes: 10 additions & 8 deletions static/js/nzbhydra.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/js/nzbhydra.js.map

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions ui-src/js/search-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,21 @@ function SearchController($scope, $http, $stateParams, $state, $window, $filter,
$scope.availableIndexers = getAvailableIndexers();


function getAndSetSearchRequests() {
SearchHistoryService.getSearchHistory(1, 20, null, null, "internal").then(function (data) {
$scope.searchHistory = data.data.searchRequests;
});
}

if ($scope.mode) {
$scope.startSearch();
} else {
//Getting the search history only makes sense when we're not currently searching
SearchHistoryService.getSearchHistory(1, 20).then(function (data) {
$scope.searchHistory = data.data.searchRequests;
});
getAndSetSearchRequests();
}

$scope.$on("searchResultsShown", function() {
SearchHistoryService.getSearchHistory(1, 20).then(function (data) {
$scope.searchHistory = data.data.searchRequests;
});
getAndSetSearchRequests();
});


Expand Down
4 changes: 2 additions & 2 deletions ui-src/js/search-history-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function SearchHistoryService($filter, $http) {
getStateParamsForRepeatedSearch: getStateParamsForRepeatedSearch
};

function getSearchHistory(pageNumber, limit, sortModel, filterModel) {
function getSearchHistory(pageNumber, limit, sortModel, filterModel, type) {
if (angular.isUndefined(pageNumber)) {
pageNumber = 1;
}
Expand All @@ -23,7 +23,7 @@ function SearchHistoryService($filter, $http) {
if (!filterModel) {
filterModel = {}
}
return $http.post("internalapi/getsearchrequests", {page: pageNumber, limit: limit, sortModel: sortModel, filterModel: filterModel}).success(function (response) {
return $http.post("internalapi/getsearchrequests", {page: pageNumber, limit: limit, sortModel: sortModel, filterModel: filterModel, type: type}).success(function (response) {
return {
searchRequests: response.searchRequests,
totalRequests: response.totalRequests
Expand Down

0 comments on commit 9cc22bf

Please sign in to comment.