|
246 | 246 | (err, isConfirmed) => { |
247 | 247 | if (isConfirmed) { |
248 | 248 | $scope.isBusy = true; |
249 | | - Deeplink.deleteById(item.id, (err, res) => { |
250 | | - if (err) { |
| 249 | + SearchEngineService.delete(item.id, (err, result)=>{ |
| 250 | + if (err){ |
251 | 251 | $scope.isBusy = false; |
252 | 252 | return console.error(err); |
253 | 253 | } |
254 | | - |
255 | | - MediaContent.delete(item.id).then(() => { |
256 | | - $scope.isBusy = false; |
257 | | - $scope.items = $scope.items.filter((_item) => _item.id !== item.id); |
258 | | - $scope.buildList(); |
259 | | - }).catch((err) => { |
260 | | - $scope.isBusy = false; |
261 | | - return console.error(err); |
| 254 | + Deeplink.deleteById(item.id, (err, res) => { |
| 255 | + if (err) { |
| 256 | + $scope.isBusy = false; |
| 257 | + return console.error(err); |
| 258 | + } |
| 259 | + |
| 260 | + MediaContent.delete(item.id).then(() => { |
| 261 | + $scope.isBusy = false; |
| 262 | + $scope.items = $scope.items.filter((_item) => _item.id !== item.id); |
| 263 | + $scope.buildList(); |
| 264 | + }).catch((err) => { |
| 265 | + $scope.isBusy = false; |
| 266 | + return console.error(err); |
| 267 | + }); |
262 | 268 | }); |
| 269 | + |
263 | 270 | }); |
264 | 271 | } |
265 | 272 | } |
|
444 | 451 |
|
445 | 452 | const searchOptions = { |
446 | 453 | filter: { '$json._buildfire.index.date1': { $gte: date } }, |
447 | | - limit: 50, skip: 0, recordCount: true |
| 454 | + limit: 50, skip: 0, recordCount: true, sort:{dateCreated: 1, rank: -1} |
448 | 455 | }; |
449 | 456 | getRecords(searchOptions, [], function (records) { |
450 | 457 | $scope.registerAnalyticsEvent(records); |
|
516 | 523 |
|
517 | 524 | if (!$rootScope.loading) |
518 | 525 | return; |
519 | | - |
520 | | - // var rank = ContentHome.info.data.content.rankOfLastItem || 0; |
521 | | - let rank = 0; |
522 | | - for (var index = 0; index < rows.length; index++) { |
523 | | - rank += 10; |
524 | | - rows[index].dateCreated = new Date().getTime(); |
525 | | - rows[index].links = []; |
526 | | - rows[index].rank = rank; |
527 | | - rows[index].body = rows[index].bodyHTML; |
528 | | - rows[index].titleIndex = rows[index].title ? rows[index].titleIndex = rows[index].title.toLowerCase() : ''; |
529 | | - //MEDIA DATE INDEX |
530 | | - var setMediaDateIndex = new Date().getTime(); |
531 | | - if (rows[index].mediaDateIndex) { |
532 | | - setMediaDateIndex = rows[index].mediaDateIndex; |
533 | | - } else if (rows[index].mediaDate) { |
534 | | - setMediaDateIndex = new Date(rows[index].mediaDate).getTime(); |
535 | | - } else if (rows[index].dateCreated) { |
536 | | - setMediaDateIndex = new Date(rows[index].dateCreated).getTime(); |
| 526 | + MediaContent.find({sort:{rank: -1}, limit:1, skip: 0}).then(function (res) { |
| 527 | + const result = res.result; |
| 528 | + // var rank = ContentHome.info.data.content.rankOfLastItem || 0; |
| 529 | + let rank = 0; |
| 530 | + if (result && result.length) { |
| 531 | + rank = result[0].rank; |
537 | 532 | } |
538 | | - rows[index].mediaDateIndex = setMediaDateIndex; |
539 | | - rows[index]._buildfire = { |
540 | | - index: { |
541 | | - date1: new Date(), |
| 533 | + for (var index = 0; index < rows.length; index++) { |
| 534 | + rank += 10; |
| 535 | + rows[index].dateCreated = new Date().getTime(); |
| 536 | + rows[index].links = []; |
| 537 | + rows[index].rank = rank; |
| 538 | + rows[index].body = rows[index].bodyHTML; |
| 539 | + rows[index].titleIndex = rows[index].title ? rows[index].titleIndex = rows[index].title.toLowerCase() : ''; |
| 540 | + //MEDIA DATE INDEX |
| 541 | + var setMediaDateIndex = new Date().getTime(); |
| 542 | + if (rows[index].mediaDateIndex) { |
| 543 | + setMediaDateIndex = rows[index].mediaDateIndex; |
| 544 | + } else if (rows[index].mediaDate) { |
| 545 | + setMediaDateIndex = new Date(rows[index].mediaDate).getTime(); |
| 546 | + } else if (rows[index].dateCreated) { |
| 547 | + setMediaDateIndex = new Date(rows[index].dateCreated).getTime(); |
542 | 548 | } |
543 | | - }; |
544 | | - } |
545 | | - if (validateCsv(rows)) { |
546 | | - MediaContent.insert(rows).then(function (data) { |
547 | | - $rootScope.loading = false; |
548 | | - $scope.isBusy = false; |
549 | | - $scope.items = []; |
550 | | - $scope.searchListItem(); |
551 | | - $scope.setDeeplinks(); |
552 | | - }, function errorHandler(error) { |
553 | | - console.error(error); |
| 549 | + rows[index].mediaDateIndex = setMediaDateIndex; |
| 550 | + rows[index]._buildfire = { |
| 551 | + index: { |
| 552 | + date1: new Date(), |
| 553 | + } |
| 554 | + }; |
| 555 | + } |
| 556 | + if (validateCsv(rows)) { |
| 557 | + MediaContent.insert(rows).then(function (data) { |
| 558 | + $rootScope.loading = false; |
| 559 | + $scope.isBusy = false; |
| 560 | + $scope.items = []; |
| 561 | + $scope.searchListItem(); |
| 562 | + $scope.setDeeplinks(); |
| 563 | + }, function errorHandler(error) { |
| 564 | + console.error(error); |
| 565 | + $rootScope.loading = false; |
| 566 | + $scope.$apply(); |
| 567 | + }); |
| 568 | + } else { |
554 | 569 | $rootScope.loading = false; |
555 | | - $scope.$apply(); |
556 | | - }); |
557 | | - } else { |
558 | | - $rootScope.loading = false; |
559 | | - $csv.showInvalidCSV(); |
560 | | - } |
| 570 | + $csv.showInvalidCSV(); |
| 571 | + } |
| 572 | + }) |
| 573 | + |
561 | 574 | } else { |
562 | 575 | $rootScope.loading = false; |
563 | 576 | $csv.showInvalidCSV(); |
|
0 commit comments