summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--db/itemmapper.php49
-rw-r--r--js/Gruntfile.js10
-rw-r--r--js/build/app.min.js1
-rw-r--r--js/package.json1
-rw-r--r--templates/main.php2
-rw-r--r--tests/unit/db/ItemMapperTest.php168
6 files changed, 149 insertions, 82 deletions
diff --git a/db/itemmapper.php b/db/itemmapper.php
index c7a0902ca..18684af82 100644
--- a/db/itemmapper.php
+++ b/db/itemmapper.php
@@ -41,7 +41,7 @@ class ItemMapper extends Mapper implements IMapper {
'ON `folders`.`id` = `feeds`.`folder_id` ' .
'WHERE `feeds`.`folder_id` = 0 ' .
'OR `folders`.`deleted_at` = 0 ' .
- 'ORDER BY `items`.`pub_date`, `items`.`id` ' . $ordering;
+ 'ORDER BY `items`.`id` ' . $ordering;
}
private function makeSelectQueryStatus($prependTo, $status, $oldestFirst=false) {
@@ -141,6 +141,15 @@ class ItemMapper extends Mapper implements IMapper {
}
+ private function getOperator($oldestFirst) {
+ if($oldestFirst) {
+ return '>';
+ } else {
+ return '<';
+ }
+ }
+
+
public function findAllNew($updatedSince, $status, $userId){
$sql = $this->makeSelectQueryStatus(
'AND `items`.`last_modified` >= ? ', $status);
@@ -166,36 +175,40 @@ class ItemMapper extends Mapper implements IMapper {
return $this->findEntities($sql, $params);
}
- private function getOperator($oldestFirst) {
- if($oldestFirst) {
- return '>';
- } else {
- return '<';
- }
- }
- public function findAllFeed($id, $limit, $offset, $status, $oldestFirst,
- $userId){
+ public function findAllFeed($id, $limit, $offset, $status, $oldestFirst, $userId){
$params = [$userId, $id];
$sql = 'AND `items`.`feed_id` = ? ';
- $sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst);
- return $this->findEntities($sql, $params, $limit, $offset);
+ if($offset !== 0){
+ $sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? ';
+ $params[] = $offset;
+ }
+ $sql = $this->makeSelectQueryStatus($sql, $status);
+ return $this->findEntities($sql, $params, $limit);
}
- public function findAllFolder($id, $limit, $offset, $status, $oldestFirst,
- $userId){
+ public function findAllFolder($id, $limit, $offset, $status, $oldestFirst, $userId){
$params = [$userId, $id];
$sql = 'AND `feeds`.`folder_id` = ? ';
- $sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst);
- return $this->findEntities($sql, $params, $limit, $offset);
+ if($offset !== 0){
+ $sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? ';
+ $params[] = $offset;
+ }
+ $sql = $this->makeSelectQueryStatus($sql, $status);
+ return $this->findEntities($sql, $params, $limit);
}
public function findAll($limit, $offset, $status, $oldestFirst, $userId){
$params = [$userId];
- $sql = $this->makeSelectQueryStatus('', $status, $oldestFirst);
- return $this->findEntities($sql, $params, $limit, $offset);
+ $sql = '';
+ if($offset !== 0){
+ $sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? ';
+ $params[] = $offset;
+ }
+ $sql = $this->makeSelectQueryStatus($sql, $status);
+ return $this->findEntities($sql, $params, $limit);
}
diff --git a/js/Gruntfile.js b/js/Gruntfile.js
index d525c9ded..6ad6d7a1c 100644
--- a/js/Gruntfile.js
+++ b/js/Gruntfile.js
@@ -15,6 +15,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-phpunit');
grunt.loadNpmTasks('grunt-wrap');
grunt.loadNpmTasks('grunt-karma');
@@ -57,6 +58,13 @@ module.exports = function (grunt) {
dest: '<%= meta.production %>app.js'
}
},
+ uglify: {
+ app: {
+ files: {
+ '<%= meta.production %>app.min.js': ['<%= meta.production %>app.js']
+ }
+ }
+ },
// in place because grunt-traceur is buggy, remove when traceur 0.0.60
// is supported
shell: {
@@ -175,7 +183,7 @@ module.exports = function (grunt) {
});
// make tasks available under simpler commands
- grunt.registerTask('default', ['jshint', 'concat', 'wrap', 'shell:traceur', 'ngAnnotate']);
+ grunt.registerTask('default', ['jshint', 'concat', 'wrap', 'shell:traceur', 'ngAnnotate', 'uglify']);
grunt.registerTask('dev', ['watch:concat']);
grunt.registerTask('test', ['karma:unit']);
grunt.registerTask('php', ['watch:phpunit']);
diff --git a/js/build/app.min.js b/js/build/app.min.js
new file mode 100644
index 000000000..fa31b57e1
--- /dev/null
+++ b/js/build/app.min.js
@@ -0,0 +1 @@
+var $__app__=function(){"use strict";return function(a,b,c,d,e,f,g){var h=c.module("News",["ngRoute","ngSanitize","ngAnimate"]);h.config(["$routeProvider","$provide","$httpProvider",function(a,b,c){var d={FEED:0,FOLDER:1,STARRED:2,SUBSCRIPTIONS:3,SHARED:4};b.constant("REFRESH_RATE",60),b.constant("ITEM_BATCH_SIZE",50),b.constant("BASE_URL",e.generateUrl("/apps/news")),b.constant("FEED_TYPE",d),b.factory("CSRFInterceptor",["$q","BASE_URL",function(a,b){return{request:function(c){return 0===c.url.indexOf(b)&&(c.headers.requesttoken=f),c||a.when(c)}}}]),c.interceptors.push("CSRFInterceptor");var h=function(a){return{data:["$http","$route","$q","BASE_URL","ITEM_BATCH_SIZE",function(b,c,d,e,f){var h={type:a,limit:f};c.current.params.id!==g&&(h.id=c.current.params.id);var i=d.defer();return b({url:e+"/items",method:"GET",params:h}).success(function(a){i.resolve(a)}),i.promise}]}};a.when("/items",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.SUBSCRIPTIONS),type:d.SUBSCRIPTIONS}).when("/items/starred",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.STARRED),type:d.STARRED}).when("/items/feeds/:id",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.FEED),type:d.FEED}).when("/items/folders/:id",{controller:"ContentController as Content",templateUrl:"content.html",resolve:h(d.FOLDER),type:d.FOLDER})}]),h.run(["$rootScope","$location","$http","$q","$interval","Loading","ItemResource","FeedResource","FolderResource","SettingsResource","Publisher","BASE_URL","FEED_TYPE","REFRESH_RATE",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){f.setLoading("global",!0),k.subscribe(g).toChannels("items","newestItemId","starred"),k.subscribe(i).toChannels("folders"),k.subscribe(h).toChannels("feeds"),k.subscribe(j).toChannels("settings");var o=d.defer();c.get(l+"/settings").success(function(a){k.publishAll(a),o.resolve()});var p=d.defer(),q=b.path();c.get(l+"/feeds/active").success(function(a){var c;switch(a.activeFeed.type){case m.FEED:c="/items/feeds/"+a.activeFeed.id;break;case m.FOLDER:c="/items/folders/"+a.activeFeed.id;break;case m.STARRED:c="/items/starred";break;default:c="/items"}/^\/items(\/(starred|feeds\/\d+|folders\/\d+))?\/?$/.test(q)||b.path(c),p.resolve()});var r=d.defer();c.get(l+"/folders").success(function(a){k.publishAll(a),r.resolve()});var s=d.defer();c.get(l+"/feeds").success(function(a){k.publishAll(a),s.resolve()}),d.all([o.promise,p.promise,s.promise,r.promise]).then(function(){f.setLoading("global",!1)}),e(function(){c.get(l+"/feeds"),c.get(l+"/folders")},1e3*n),a.$on("$routeChangeStart",function(){f.setLoading("content",!0)}),a.$on("$routeChangeSuccess",function(){f.setLoading("content",!1)}),a.$on("$routeChangeError",function(){b.path("/items")})}]),h.controller("AppController",["Loading","FeedResource","FolderResource",function(a,b,c){this.loading=a,this.isFirstRun=function(){return 0===b.size()&&0===c.size()}}]),h.controller("ContentController",["Publisher","FeedResource","ItemResource","SettingsResource","data","$route","$routeParams",function(a,b,c,d,e,f,h){var i=this;c.clear(),a.publishAll(e),this.isAutoPagingEnabled=!0,this.getItems=function(){return c.getAll()},this.toggleStar=function(a){c.toggleStar(a)},this.markRead=function(a){var d=c.get(a);d.keepUnread||(c.markItemRead(a),b.markItemOfFeedRead(d.feedId))},this.getFeed=function(a){return b.getById(a)},this.toggleKeepUnread=function(a){var d=c.get(a);d.unread||(b.markItemOfFeedUnread(d.feedId),c.markItemRead(a,!1)),d.keepUnread=!d.keepUnread},this.orderBy=function(){return d.get("oldestFirst")?"-id":"id"},this.isCompactView=function(){return d.get("compact")},this.autoPagingEnabled=function(){return i.isAutoPagingEnabled},this.markReadEnabled=function(){return!d.get("preventReadOnScroll")},this.scrollRead=function(a){for(var d,e,f,g=[],h=[],i=a[$traceurRuntime.toProperty(Symbol.iterator)]();!(f=i.next()).done;)d=f.value,e=c.get(d),e.keepUnread||(g.push(d),h.push(e.feedId));b.markItemsOfFeedsRead(h),c.markItemsRead(g)},this.autoPage=function(){i.isAutoPagingEnabled=!1;var b=f.current.$$route.type,d=h.id;c.autoPage(b,d).success(function(b){a.publishAll(b),b.items.length>0&&(i.isAutoPagingEnabled=!0)}).error(function(){i.isAutoPagingEnabled=!0})},this.getRelativeDate=function(a){var b,c;return a!==g&&""!==a?(b=d.get("language"),c=moment.unix(a).locale(b).fromNow()+""):""}}]),h.controller("NavigationController",["$route","FEED_TYPE","FeedResource","FolderResource","ItemResource","SettingsResource",function(a,b,c,d,e,f){var h=this;this.feedError="",this.folderError="",this.getFeeds=function(){return c.getAll()},this.getFolders=function(){return d.getAll()},this.markFolderRead=function(a){var b;c.markFolderRead(a);for(var d,f=c.getByFolderId(a)[$traceurRuntime.toProperty(Symbol.iterator)]();!(d=f.next()).done;)b=d.value,e.markFeedRead(b.id)},this.markFeedRead=function(a){e.markFeedRead(a),c.markFeedRead(a)},this.markRead=function(){e.markRead(),c.markRead()},this.isShowAll=function(){return f.get("showAll")},this.getFeedsOfFolder=function(a){return c.getByFolderId(a)},this.getUnreadCount=function(){return c.getUnreadCount()},this.getFeedUnreadCount=function(a){return c.getById(a).unreadCount},this.getFolderUnreadCount=function(a){return c.getFolderUnreadCount(a)},this.getStarredCount=function(){return e.getStarredCount()},this.toggleFolder=function(a){d.toggleOpen(a)},this.hasFeeds=function(a){return c.getFolderUnreadCount(a)!==g},this.subFeedActive=function(d){var e,f=a.current.$$route.type;return f===b.FEED&&(e=c.getById(a.current.params.id),e.folderId===d)?!0:!1},this.isSubscriptionsActive=function(){return a.current&&a.current.$$route.type===b.SUBSCRIPTIONS},this.isStarredActive=function(){return a.current&&a.current.$$route.type===b.STARRED},this.isFolderActive=function(c){var d=parseInt(a.current.params.id,10);return a.current&&a.current.$$route.type===b.FOLDER&&d===c},this.isFeedActive=function(c){var d=parseInt(a.current.params.id,10);return a.current&&a.current.$$route.type===b.FEED&&d===c},this.folderNameExists=function(a){return d.get(a)!==g},this.isAddingFolder=function(){return!0},this.createFolder=function(a){console.log(a.name),a.name=""},this.createFeed=function(a){h.newFolder=!1,console.log(a.url+a.folder),a.url=""},this.cancelRenameFolder=function(a){console.log(a)},this.renameFeed=function(a,b){console.log(a+b)},this.cancelRenameFeed=function(a){console.log(a)},this.renameFolder=function(){console.log("TBD")},this.deleteFeed=function(a){console.log(a)},this.deleteFolder=function(a){console.log(a)},this.moveFeed=function(a,b){console.log(a+b)}}]),h.controller("SettingsController",["$route","SettingsResource","FeedResource",function(a,b,c){var d=this;this.importing=!1,this.opmlImportError=!1,this.articleImportError=!1;var e=function(c,d){b.set(c,d),["showAll","oldestFirst"].indexOf(c)>=0&&a.reload()};this.toggleSetting=function(a){e(a,!d.getSetting(a))},this.getSetting=function(a){return b.get(a)},this.feedSize=function(){return c.size()},this.importOpml=function(a){console.log(a)},this.importArticles=function(a){console.log(a)}}]),h.filter("trustUrl",["$sce",function(a){return function(b){return a.trustAsResourceUrl(b)}}]),h.filter("unreadCountFormatter",function(){return function(a){return a>999?"999+":a}}),h.factory("FeedResource",["Resource","$http","BASE_URL",function(a,b,c){var d=function(a,b){$traceurRuntime.superCall(this,e.prototype,"constructor",[a,b,"url"]),this.ids={},this.unreadCount=0,this.folderUnreadCount={},this.folderIds={},this.deleted=null},e=d;return $traceurRuntime.createClass(d,{receive:function(a){$traceurRuntime.superCall(this,e.prototype,"receive",[a]),this.updateUnreadCache(),this.updateFolderCache()},updateUnreadCache:function(){var a,b,c,d,e,f;this.unreadCount=0,this.folderUnreadCount={};for(var h,i=this.values[$traceurRuntime.toProperty(Symbol.iterator)]();!(h=i.next()).done;)f=h.value,f.unreadCount&&(this.unreadCount+=f.unreadCount),f.folderId!==g&&($traceurRuntime.setProperty(this.folderUnreadCount,f.folderId,this.folderUnreadCount[$traceurRuntime.toProperty(f.folderId)]||0),a=this.folderUnreadCount,b=f.folderId,c=f.unreadCount,d=a[$traceurRuntime.toProperty(b)],e=d+c,$traceurRuntime.setProperty(a,b,e),e)},updateFolderCache:function(){var a;this.folderIds={};for(var b,c=this.values[$traceurRuntime.toProperty(Symbol.iterator)]();!(b=c.next()).done;)a=b.value,$traceurRuntime.setProperty(this.folderIds,a.folderId,this.folderIds[$traceurRuntime.toProperty(a.folderId)]||[]),this.folderIds[$traceurRuntime.toProperty(a.folderId)].push(a)},add:function(a){$traceurRuntime.superCall(this,e.prototype,"add",[a]),a.id!==g&&$traceurRuntime.setProperty(this.ids,a.id,this.hashMap[$traceurRuntime.toProperty(a.url)])},"delete":function(a){var b=this.get(a);return this.deleted=b,delete this.ids[$traceurRuntime.toProperty(b.id)],$traceurRuntime.superCall(this,e.prototype,"delete",[a]),this.updateUnreadCache(),this.updateFolderCache(),this.http.delete(this.BASE_URL+"/feeds/"+b.id)},markRead:function(){for(var a,b,c=this.values[$traceurRuntime.toProperty(Symbol.iterator)]();!(b=c.next()).done;)a=b.value,a.unreadCount=0;this.unreadCount=0,this.folderUnreadCount={}},markFeedRead:function(a){this.ids[$traceurRuntime.toProperty(a)].unreadCount=0,this.updateUnreadCache()},markFolderRead:function(a){for(var b,c,d=this.values[$traceurRuntime.toProperty(Symbol.iterator)]();!(c=d.next()).done;)b=c.value,b.folderId===a&&(b.unreadCount=0);this.updateUnreadCache()},markItemOfFeedRead:function(a){this.ids[$traceurRuntime.toProperty(a)].unreadCount-=1,this.updateUnreadCache()},markItemsOfFeedsRead:function(a){for(var b,c,d=a[$traceurRuntime.toProperty(Symbol.iterator)]();!(c=d.next()).done;)b=c.value,this.ids[$traceurRuntime.toProperty(b)].unreadCount-=1;this.updateUnreadCache()},markItemOfFeedUnread:function(a){this.ids[$traceurRuntime.toProperty(a)].unreadCount+=1,this.updateUnreadCache()},getUnreadCount:function(){return this.unreadCount},getFolderUnreadCount:function(a){return this.folderUnreadCount[$traceurRuntime.toProperty(a)]},getByFolderId:function(a){return this.folderIds[$traceurRuntime.toProperty(a)]||[]},getById:function(a){return this.ids[$traceurRuntime.toProperty(a)]},rename:function(a,b){var c=this.get(a);return c.title=b,this.http({method:"POST",url:this.BASE_URL+"/feeds/"+c.id+"/rename",data:{feedTitle:b}})},move:function(a,b){var c=this.get(a);return c.folderId=b,this.updateFolderCache(),this.http({method:"POST",url:this.BASE_URL+"/feeds/"+c.id+"/move",data:{parentFolderId:b}})},create:function(a,b){var c=void 0!==arguments[2]?arguments[2]:null;c&&(c=c.toUpperCase());var d={url:a,folderId:b,title:c,faviconLink:"../css/loading.gif"};this.get(a)||this.add(d),this.updateFolderCache(),console.log(d)},undoDelete:function(){return this.deleted?(this.add(this.deleted),this.http.post(this.BASE_URL+"/feeds/"+this.deleted.id+"/restore")):(this.updateFolderCache(),void this.updateUnreadCache())}},{},a),new d(b,c)}]),h.factory("FolderResource",["Resource","$http","BASE_URL",function(a,b,c){var d=function(a,b){$traceurRuntime.superCall(this,e.prototype,"constructor",[a,b,"name"]),this.deleted=null},e=d;return $traceurRuntime.createClass(d,{"delete":function(a){var b=this.get(a);return this.deleted=b,$traceurRuntime.superCall(this,e.prototype,"delete",[a]),this.http.delete(this.BASE_URL+"/folders/"+b.id)},toggleOpen:function(a){var b=this.get(a);return b.opened=!b.opened,this.http({url:this.BASE_URL+"/folders/"+b.id+"/open",method:"POST",data:{folderId:b.id,open:b.opened}})},rename:function(a,b){b=b.toUpperCase();var c=this.get(a);return this.get(b)||(c.name=b,delete this.hashMap[$traceurRuntime.toProperty(a)],$traceurRuntime.setProperty(this.hashMap,b,c)),this.http({url:this.BASE_URL+"/folders/"+c.id+"/rename",method:"POST",data:{folderName:b}})},create:function(a){var b;return a=a.toUpperCase(),this.get(a)||(b={name:a},this.add(b)),this.http({url:this.BASE_URL+"/folders",method:"POST",data:{folderName:a}})},undoDelete:function(){return this.deleted?(this.add(this.deleted),this.http.post(this.BASE_URL+"/folders/"+this.deleted.id+"/restore")):void 0}},{},a),new d(b,c)}]),h.factory("ItemResource",["Resource","$http","BASE_URL","ITEM_BATCH_SIZE",function(a,b,c,d){var e=function(a,b,c){$traceurRuntime.superCall(this,f.prototype,"constructor",[a,b]),this.starredCount=0,this.batchSize=c},f=e;return $traceurRuntime.createClass(e,{receive:function(a,b){switch(b){case"newestItemId":this.newestItemId=a;break;case"starred":this.starredCount=a;break;default:$traceurRuntime.superCall(this,f.prototype,"receive",[a,b])}},getNewestItemId:function(){return this.newestItemId},getStarredCount:function(){return this.starredCount},star:function(a){var b=void 0!==arguments[1]?arguments[1]:!0,c=this.get(a),d=this.BASE_URL+"/items/"+c.feedId+"/"+c.guidHash+"/star";return c.starred=b,b?this.starredCount+=1:this.starredCount-=1,this.http({url:d,method:"POST",data:{isStarred:b}})},toggleStar:function(a){this.get(a).starred?this.star(a,!1):this.star(a,!0)},markItemRead:function(a){var b=void 0!==arguments[1]?arguments[1]:!0;return this.get(a).unread=!b,this.http({url:this.BASE_URL+"/items/"+a+"/read",method:"POST",data:{isRead:b}})},markItemsRead:function(a){for(var b,c,d=a[$traceurRuntime.toProperty(Symbol.iterator)]();!(c=d.next()).done;)b=c.value,this.get(b).unread=!1;return this.http({url:this.BASE_URL+"/items/read/multiple",method:"POST",data:{itemIds:a}})},markFeedRead:function(a){for(var b,c,d=void 0!==arguments[1]?arguments[1]:!0,e=this.values.filter(function(b){return b.feedId===a})[$traceurRuntime.toProperty(Symbol.iterator)]();!(c=e.next()).done;)b=c.value,b.unread=!d;return this.http.post(this.BASE_URL+"/feeds/"+a+"/read")},markRead:function(){for(var a,b,c=this.values[$traceurRuntime.toProperty(Symbol.iterator)]();!(b=c.next()).done;)a=b.value,a.unread=!1;return this.http.post(this.BASE_URL+"/items/read")},autoPage:function(a,b){return this.http({url:this.BASE_URL+"/items",method:"GET",params:{type:a,id:b,offset:this.size(),limit:this.batchSize}})}},{},a),new e(b,c,d)}]),h.service("Loading",function(){var a=this;this.loading={global:!1,content:!1,autopaging:!1},this.setLoading=function(b,c){$traceurRuntime.setProperty(a.loading,b,c)},this.isLoading=function(b){return a.loading[$traceurRuntime.toProperty(b)]}}),h.service("Publisher",function(){var a=this;this.channels={},this.subscribe=function(b){return{toChannels:function(){for(var c,d=[],e=0;e<arguments.length;e++)$traceurRuntime.setProperty(d,e,arguments[$traceurRuntime.toProperty(e)]);for(var f,g=d[$traceurRuntime.toProperty(Symbol.iterator)]();!(f=g.next()).done;)c=f.value,$traceurRuntime.setProperty(a.channels,c,a.channels[$traceurRuntime.toProperty(c)]||[]),a.channels[$traceurRuntime.toProperty(c)].push(b)}}},this.publishAll=function(b){for(var c,d,e,f,h,i=items(b)[$traceurRuntime.toProperty(Symbol.iterator)]();!(h=i.next()).done;)if(c=h.value,d=c[0],e=c[1],a.channels[$traceurRuntime.toProperty(d)]!==g)for(var j,k=a.channels[$traceurRuntime.toProperty(d)][$traceurRuntime.toProperty(Symbol.iterator)]();!(j=k.next()).done;)f=j.value,f.receive(e,d)}}),h.factory("Resource",function(){var a=function(a,b){var c=void 0!==arguments[2]?arguments[2]:"id";this.id=c,this.values=[],this.hashMap={},this.http=a,this.BASE_URL=b};return $traceurRuntime.createClass(a,{receive:function(a){for(var b,c,d=a[$traceurRuntime.toProperty(Symbol.iterator)]();!(c=d.next()).done;)b=c.value,this.add(b)},add:function(a){var b,c,d,e=this.hashMap[$traceurRuntime.toProperty(a[$traceurRuntime.toProperty(this.id)])];if(e===g)this.values.push(a),$traceurRuntime.setProperty(this.hashMap,a[$traceurRuntime.toProperty(this.id)],a);else for(var f,h=items(a)[$traceurRuntime.toProperty(Symbol.iterator)]();!(f=h.next()).done;)b=f.value,c=b[0],d=b[1],$traceurRuntime.setProperty(e,c,d)},size:function(){return this.values.length},get:function(a){return this.hashMap[$traceurRuntime.toProperty(a)]},"delete":function(a){var b=this,c=this.values.findIndex(function(c){return c[$traceurRuntime.toProperty(b.id)]===a});c!==g&&this.values.splice(c,1),this.hashMap[$traceurRuntime.toProperty(a)]!==g&&delete this.hashMap[$traceurRuntime.toProperty(a)]},clear:function(){for(this.hashMap={};this.values.length>0;)this.values.pop()},getAll:function(){return this.values}},{}),a}),h.service("SettingsResource",["$http","BASE_URL",function(a,b){var c=this;this.settings={language:"en",showAll:!1,compact:!1,oldestFirst:!1},this.defaultLanguageCode="en",this.supportedLanguageCodes=["ar-ma","ar","bg","ca","cs","cv","da","de","el","en-ca","en-gb","eo","es","et","eu","fi","fr-ca","fr","gl","he","hi","hu","id","is","it","ja","ka","ko","lv","ms-my","nb","ne","nl","pl","pt-br","pt","ro","ru","sk","sl","sv","th","tr","tzm-la","tzm","uk","zh-cn","zh-tw"],this.receive=function(a){for(var b,d,e,f,g=items(a)[$traceurRuntime.toProperty(Symbol.iterator)]();!(f=g.next()).done;)b=f.value,d=b[0],e=b[1],"language"===d&&(e=c.processLanguageCode(e)),$traceurRuntime.setProperty(c.settings,d,e)},this.get=function(a){return c.settings[$traceurRuntime.toProperty(a)]},this.set=function(d,e){$traceurRuntime.setProperty(c.settings,d,e);var f={};return $traceurRuntime.setProperty(f,d,e),a({url:b+"/settings",method:"POST",data:f})},this.processLanguageCode=function(a){return a=a.replace("_","-").toLowerCase(),c.supportedLanguageCodes.indexOf(a)<0&&(a=a.split("-")[0]),c.supportedLanguageCodes.indexOf(a)<0&&(a=c.defaultLanguageCode),a}}]),function(a,b,c){var d=c("#app-content"),e=function(a){return!(a.is("input")||a.is("select")||a.is("textarea")||a.is("checkbox"))},f=function(a){return!(a.shiftKey||a.altKey||a.ctrlKey||a.metaKey)},g=function(a,b){b.scrollTop(a.offset().top-b.offset().top+b.scrollTop())},h=function(a){for(var b,d,e=a.find(".item"),f=e[$traceurRuntime.toProperty(Symbol.iterator)]();!(d=f.next()).done;)if(b=d.value,b=c(b),b.position().top>1)return void g(a,b);a.scrollTop(a.prop("scrollHeight"))},i=function(a){for(var b,d,e,f=a.find(".item"),h=f[$traceurRuntime.toProperty(Symbol.iterator)]();!(e=h.next()).done;)if(b=e.value,b=c(b),b.position().top>=0)return d=b.prev(),void(d.length>0&&g(a,d));f.length>0&&g(a,f.last())},j=function(a){for(var b,d,e=a.find(".item"),f=e[$traceurRuntime.toProperty(Symbol.iterator)]();!(d=f.next()).done;)if(b=d.value,b=c(b),b.height()+b.position().top>30)return b},k=function(a){var b=j(a);b.find(".keep_unread").trigger("click")},l=function(a){var b=j(a);b.find(".item_utils .star").trigger("click")},m=function(a){var b=j(a);b.find(".item_heading a").trigger("click")},n=function(b){var c=j(b).find(".item_title a");c.trigger("click"),a.open(c.attr("href"),"_blank")};c(b).keyup(function(a){var b=a.keyCode;e(c(":focus"))&&f(a)&&([74,78,34].indexOf(b)>=0?(a.preventDefault(),h(d)):[75,80,37].indexOf(b)>=0?(a.preventDefault(),i(d)):[85].indexOf(b)>=0?(a.preventDefault(),k(d)):[69].indexOf(b)>=0?(a.preventDefault(),m(d)):[73,83,76].indexOf(b)>=0?(a.preventDefault(),l(d)):[72].indexOf(b)>=0?(a.preventDefault(),l(d),h(d)):[79].indexOf(b)>=0&&(a.preventDefault(),n(d)))})}(a,b,jQuery);var i=Function.prototype.call.bind(Function.prototype.call),j=Object.prototype.hasOwnProperty;a.items=function(a){var b;return b={},Object.defineProperty(b,Symbol.iterator,{value:function(){return $traceurRuntime.initGeneratorFunction(function b(){var c,d,e,f,g;return $traceurRuntime.createGeneratorInstance(function(b){for(;;)switch(b.state){case 0:c=[],d=a;for(e in d)c.push(e);b.state=15;break;case 15:f=0,b.state=13;break;case 13:b.state=f<c.length?9:-2;break;case 4:f++,b.state=13;break;case 9:g=c[$traceurRuntime.toProperty(f)],b.state=10;break;case 10:b.state=$traceurRuntime.toProperty(g)in d?7:4;break;case 7:b.state=i(j,a,g)?1:4;break;case 1:return b.state=2,[g,a[$traceurRuntime.toProperty(g)]];case 2:b.maybeThrow(),b.state=4;break;default:return b.end()}},b,this)})()},configurable:!0,enumerable:!0,writable:!0}),b},a.enumerate=function(a){var b;return b={},Object.defineProperty(b,Symbol.iterator,{value:function(){return $traceurRuntime.initGeneratorFunction(function b(){var c;return $traceurRuntime.createGeneratorInstance(function(b){for(;;)switch(b.state){case 0:c=0,b.state=7;break;case 7:b.state=c<a.length?1:-2;break;case 4:c+=1,b.state=7;break;case 1:return b.state=2,[c,a[$traceurRuntime.toProperty(c)]];case 2:b.maybeThrow(),b.state=4;break;default:return b.end()}},b,this)})()},configurable:!0,enumerable:!0,writable:!0}),b},a.reverse=function(a){var b;return b={},Object.defineProperty(b,Symbol.iterator,{value:function(){return $traceurRuntime.initGeneratorFunction(function b(){var c;return $traceurRuntime.createGeneratorInstance(function(b){for(;;)switch(b.state){case 0:c=a.length,b.state=7;break;case 7:b.state=c>=0?1:-2;break;case 4:c-=1,b.state=7;break;case 1:return b.state=2,a[$traceurRuntime.toProperty(c)];case 2:b.maybeThrow(),b.state=4;break;default:return b.end()}},b,this)})()},configurable:!0,enumerable:!0,writable:!0}),b},h.run(["$document","$rootScope",function(a,b){a.click(function(a){b.$broadcast("documentClicked",a)})}]),h.directive("appNavigationEntryUtils",function(){return{restrict:"C",link:function(a,b){var c=b.siblings(".app-navigation-entry-menu"),e=d(b).find(".app-navigation-entry-utils-menu-button button");e.click(function(){c.toggleClass("open")}),a.$on("documentClicked",function(a,b){b.target!==e[0]&&c.removeClass("open")})}}}),h.directive("newsAudio",function(){return{restrict:"E",scope:{src:"@",type:"@"},transclude:!0,template:'<audio controls="controls" preload="none" ng-hide="cantPlay()"><source ng-src="{{ src|trustUrl }}"></audio><a ng-href="{{ src|trustUrl }}" class="button" ng-show="cantPlay()" ng-transclude></a>',link:function(a,b){var c=b.children().children("source")[0],d=!1;c.addEventListener("error",function(){a.$apply(function(){d=!0})}),a.cantPlay=function(){return d}}}}),h.directive("newsAutoFocus",function(){return function(a,b,c){c.newsAutofocus?d(c.newsAutofocus).focus():b.focus()}}),h.directive("newsBindHtmlUnsafe",function(){return function(a,b,c){a.$watch(c.newsBindHtmlUnsafe,function(){b.html(a.$eval(c.newsBindHtmlUnsafe))})}}),h.directive("newsDraggable",function(){return function(a,b,d){var e=a.$eval(d.newsDraggable);c.isDefined(e)?b.draggable(e):b.draggable()}}),h.directive("newsDroppable",["$rootScope",function(a){return function(b,c,e){var f={accept:".feed",hoverClass:"drag-and-drop",greedy:!0,drop:function(f,g){d(".drag-and-drop").removeClass("drag-and-drop");var h={folderId:parseInt(c.data("id"),10),feedId:parseInt(d(g.draggable).data("id"),10)};a.$broadcast("moveFeedToFolder",h),b.$apply(e.droppable)}};c.droppable(f)}}]),h.directive("newsFocus",["$timeout","$interpolate",function(a,b){return function(c,e,f){e.click(function(){var e=d(b(f.newsFocus)(c));a(function(){e.focus()},500)})}}]),h.directive("newsReadFile",function(){return function(a,b,c){b.change(function(){var d=b[0].files[0],e=new FileReader;e.onload=function(d){b[0].value=0,a.$fileContent=d.target.result,a.$apply(c.newsReadFile)},e.readAsText(d)})}}),h.directive("newsScroll",["$timeout",function(a){var b=function(a,b,c,e){var f,g,h;if(a){f=0,g=c.find(".item");for(var i=g.length-1;i>=0&&(h=d(g[$traceurRuntime.toProperty(i)]),!(f>=b));i-=1){if(h.position().top<0){e.$apply(e.newsScrollAutoPage);break}f+=1}}},c=function(a,b,c){var e,f,g;if(a){e=[],f=b.find(".item:not(.read)");for(var h=0;h<f.length&&(g=d(f[$traceurRuntime.toProperty(h)]),g.position().top<=-50);h+=1)e.push(parseInt(g.data("id"),10));c.itemIds=e,c.$apply(c.newsScrollMarkRead)}};return{restrict:"A",scope:{newsScrollAutoPage:"&",newsScrollMarkRead:"&",newsScrollEnabledMarkRead:"=",newsScrollEnabledAutoPage:"=",newsScrollMarkReadTimeout:"@",newsScrollTimeout:"@",newsScrollAutoPageWhenLeft:"@"},link:function(d,e){var f=!0,g=d.newsScrollTimeout||1,h=d.newsScrollMarkReadTimeout||1,i=d.newsScrollAutoPageWhenLeft||50,j=function(){f&&(f=!1,a(function(){f=!0},1e3*g),b(d.newsScrollEnabledAutoPage,i,e,d),a(function(){c(d.newsScrollEnabledMarkRead,e,d)},1e3*h))};e.on("scroll",j),d.$on("$destroy",function(){e.off("scroll",j)})}}}]),h.directive("newsTitleUnreadCount",["$window",function(a){var b=a.document.title;return{restrict:"E",scope:{unreadCount:"@"},link:function(c,d,e){e.$observe("unreadCount",function(c){var d=b.split("-");"0"!==c&&(a.document.title=d[0]+"("+c+") - "+d[1])})}}}]),h.directive("newsTriggerClick",function(){return function(a,b,c){b.click(function(){d(c.newsTriggerClick).trigger("click")})}})}(window,document,angular,jQuery,OC,oc_requesttoken),{}}(); \ No newline at end of file
diff --git a/js/package.json b/js/package.json
index 48179eb57..7a32f3397 100644
--- a/js/package.json
+++ b/js/package.json
@@ -29,6 +29,7 @@
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-connect": "^0.8.0",
"grunt-contrib-jshint": "^0.10.0",
+ "grunt-contrib-uglify": "^0.5.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-karma": "^0.9.0",
"grunt-ng-annotate": "^0.3.2",
diff --git a/templates/main.php b/templates/main.php
index c548d9371..f1ee191a4 100644
--- a/templates/main.php
+++ b/templates/main.php
@@ -5,7 +5,7 @@
\OCP\Util::addScript('news', 'vendor/angular-sanitize/angular-sanitize.min');
\OCP\Util::addScript('news', 'vendor/angular-animate/angular-animate.min');
\OCP\Util::addScript('news', 'vendor/momentjs/min/moment-with-locales.min');
-\OCP\Util::addScript('news', 'build/app');
+\OCP\Util::addScript('news', 'build/app.min');
\OCP\Util::addStyle('news', 'app');
\OCP\Util::addStyle('news', 'navigation');
diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php
index 6b5082d9b..2fadd50cf 100644
--- a/tests/unit/db/ItemMapperTest.php
+++ b/tests/unit/db/ItemMapperTest.php
@@ -27,7 +27,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function setUp() {
- parent::setUp();
+ parent::setup();
$this->mapper = new ItemMapper($this->db);
@@ -35,20 +35,23 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$item1 = new Item();
$item2 = new Item();
- $this->items = [$item1, $item2];
+ $this->items = array(
+ $item1,
+ $item2
+ );
$this->userId = 'john';
$this->id = 3;
$this->folderId = 2;
- $this->row = [
- ['id' => $this->items[0]->getId()],
- ];
+ $this->row = array(
+ array('id' => $this->items[0]->getId()),
+ );
- $this->rows = [
- ['id' => $this->items[0]->getId()],
- ['id' => $this->items[1]->getId()]
- ];
+ $this->rows = array(
+ array('id' => $this->items[0]->getId()),
+ array('id' => $this->items[1]->getId())
+ );
$this->user = 'john';
$this->limit = 10;
@@ -61,12 +64,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
}
- private function makeSelectQuery($prependTo, $oldestFirst=false){
- if($oldestFirst) {
- $ordering = 'ASC';
- } else {
- $ordering = 'DESC';
- }
+ private function makeSelectQuery($prependTo){
return 'SELECT `items`.* FROM `*PREFIX*news_items` `items` '.
'JOIN `*PREFIX*news_feeds` `feeds` ' .
'ON `feeds`.`id` = `items`.`feed_id` '.
@@ -77,15 +75,15 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'ON `folders`.`id` = `feeds`.`folder_id` ' .
'WHERE `feeds`.`folder_id` = 0 ' .
'OR `folders`.`deleted_at` = 0 ' .
- 'ORDER BY `items`.`pub_date`, `items`.`id` ' . $ordering;
+ 'ORDER BY `items`.`id` DESC';
}
- private function makeSelectQueryStatus($prependTo, $status, $oldestFirst=false) {
+ private function makeSelectQueryStatus($prependTo, $status) {
$status = (int) $status;
return $this->makeSelectQuery(
'AND ((`items`.`status` & ' . $status . ') = ' . $status . ') ' .
- $prependTo, $oldestFirst
+ $prependTo
);
}
@@ -93,7 +91,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFind(){
$sql = $this->makeSelectQuery('AND `items`.`id` = ? ');
- $this->setMapperResult($sql, [$this->userId, $this->id], $this->row);
+ $this->setMapperResult($sql, array($this->userId, $this->id), $this->row);
$result = $this->mapper->find($this->id, $this->userId);
$this->assertEquals($this->items[0], $result);
@@ -102,7 +100,9 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testGetStarredCount(){
$userId = 'john';
- $row = [['size' => 9]];
+ $row = array(
+ array('size' => 9)
+ );
$sql = 'SELECT COUNT(*) AS size FROM `*PREFIX*news_feeds` `feeds` ' .
'JOIN `*PREFIX*news_items` `items` ' .
'ON `items`.`feed_id` = `feeds`.`id` ' .
@@ -110,7 +110,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'WHERE ((`items`.`status` & ' . StatusFlag::STARRED . ') = '
. StatusFlag::STARRED . ')';
- $this->setMapperResult($sql, [$userId], $row);
+ $this->setMapperResult($sql, array($userId), $row);
$result = $this->mapper->starredCount($userId);
$this->assertEquals($row[0]['size'], $result);
@@ -126,7 +126,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'WHERE `user_id` = ? ' .
') '.
'AND `id` <= ?';
- $params = [~StatusFlag::UNREAD, $this->updatedSince, $this->user, 3];
+ $params = array(~StatusFlag::UNREAD, $this->updatedSince, $this->user, 3);
$this->setMapperResult($sql, $params);
$this->mapper->readAll(3, $this->updatedSince, $this->user);
}
@@ -142,7 +142,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `user_id` = ? ' .
') '.
'AND `id` <= ?';
- $params = [~StatusFlag::UNREAD, $this->updatedSince, 3, $this->user, 6];
+ $params = array(~StatusFlag::UNREAD, $this->updatedSince, 3, $this->user, 6);
$this->setMapperResult($sql, $params);
$this->mapper->readFolder(3, 6, $this->updatedSince, $this->user);
}
@@ -158,7 +158,8 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'SELECT * FROM `*PREFIX*news_feeds` ' .
'WHERE `user_id` = ? ' .
'AND `id` = ? ) ';
- $params = [~StatusFlag::UNREAD, $this->updatedSince, 3, 6, $this->user, 3];
+ $params = array(~StatusFlag::UNREAD, $this->updatedSince, 3, 6,
+ $this->user, 3);
$this->setMapperResult($sql, $params);
$this->mapper->readFeed(3, 6, $this->updatedSince, $this->user);
}
@@ -167,7 +168,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFindAllNew(){
$sql = 'AND `items`.`last_modified` >= ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = [$this->user, $this->updatedSince];
+ $params = array($this->user, $this->updatedSince);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllNew($this->updatedSince,
@@ -182,7 +183,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `items`.`last_modified` >= ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = [$this->user, $this->id, $this->updatedSince];
+ $params = array($this->user, $this->id, $this->updatedSince);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllNewFolder($this->id, $this->updatedSince,
$this->status, $this->user);
@@ -195,7 +196,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$sql = 'AND `items`.`feed_id` = ? ' .
'AND `items`.`last_modified` >= ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = [$this->user, $this->id, $this->updatedSince];
+ $params = array($this->user, $this->id, $this->updatedSince);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllNewFeed($this->id, $this->updatedSince,
@@ -209,7 +210,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$status = StatusFlag::UNREAD | StatusFlag::STARRED;
$sql = 'AND ((`items`.`status` & ' . $status . ') > 0) ';
$sql = $this->makeSelectQuery($sql);
- $params = [$this->user];
+ $params = array($this->user);
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllUnreadOrStarred($this->user);
@@ -218,10 +219,11 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFindAllFeed(){
- $sql = 'AND `items`.`feed_id` = ? ';
+ $sql = 'AND `items`.`feed_id` = ? ' .
+ 'AND `items`.`id` < ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = [$this->user, $this->id];
- $this->setMapperResult($sql, $params, $this->rows, $this->limit, $this->offset);
+ $params = array($this->user, $this->id, $this->offset);
+ $this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFeed($this->id, $this->limit,
$this->offset, $this->status, false, $this->user);
@@ -230,10 +232,11 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFindAllFeedOldestFirst(){
- $sql = 'AND `items`.`feed_id` = ? ';
- $sql = $this->makeSelectQueryStatus($sql, $this->status, true);
- $params = [$this->user, $this->id];
- $this->setMapperResult($sql, $params, $this->rows, $this->limit, $this->offset);
+ $sql = 'AND `items`.`feed_id` = ? ' .
+ 'AND `items`.`id` > ? ';
+ $sql = $this->makeSelectQueryStatus($sql, $this->status);
+ $params = array($this->user, $this->id, $this->offset);
+ $this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFeed($this->id, $this->limit,
$this->offset, $this->status, true, $this->user);
@@ -241,11 +244,25 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
}
+ public function testFindAllFeedOffsetZero(){
+ $sql = 'AND `items`.`feed_id` = ? ';
+ $sql = $this->makeSelectQueryStatus($sql, $this->status);
+ $params = array($this->user, $this->id);
+ $this->setMapperResult($sql, $params, $this->rows);
+ $result = $this->mapper->findAllFeed($this->id, $this->limit,
+ 0, $this->status, false, $this->user);
+
+ $this->assertEquals($this->items, $result);
+ }
+
+
public function testFindAllFolder(){
- $sql = 'AND `feeds`.`folder_id` = ? ';
+ $sql = 'AND `feeds`.`folder_id` = ? ' .
+ 'AND `items`.`id` < ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = [$this->user, $this->id];
- $this->setMapperResult($sql, $params, $this->rows, $this->limit, $this->offset);
+ $params = array($this->user, $this->id,
+ $this->offset);
+ $this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFolder($this->id, $this->limit,
$this->offset, $this->status, false, $this->user);
@@ -254,10 +271,12 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFindAllFolderOldestFirst(){
- $sql = 'AND `feeds`.`folder_id` = ? ';
- $sql = $this->makeSelectQueryStatus($sql, $this->status, true);
- $params = [$this->user, $this->id];
- $this->setMapperResult($sql, $params, $this->rows, $this->limit, $this->offset);
+ $sql = 'AND `feeds`.`folder_id` = ? ' .
+ 'AND `items`.`id` > ? ';
+ $sql = $this->makeSelectQueryStatus($sql, $this->status);
+ $params = array($this->user, $this->id,
+ $this->offset);
+ $this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFolder($this->id, $this->limit,
$this->offset, $this->status, true, $this->user);
@@ -265,11 +284,23 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
}
+ public function testFindAllFolderOffsetZero(){
+ $sql = 'AND `feeds`.`folder_id` = ? ';
+ $sql = $this->makeSelectQueryStatus($sql, $this->status);
+ $params = array($this->user, $this->id);
+ $this->setMapperResult($sql, $params, $this->rows);
+ $result = $this->mapper->findAllFolder($this->id, $this->limit,
+ 0, $this->status, false, $this->user);
+
+ $this->assertEquals($this->items, $result);
+ }
+
+
public function testFindAll(){
- $sql = '';
+ $sql = 'AND `items`.`id` < ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = [$this->user];
- $this->setMapperResult($sql, $params, $this->rows, $this->limit, $this->offset);
+ $params = array($this->user, $this->offset);
+ $this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAll($this->limit,
$this->offset, $this->status, false, $this->user);
@@ -278,10 +309,10 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFindAllOldestFirst(){
- $sql = '';
- $sql = $this->makeSelectQueryStatus($sql, $this->status, true);
- $params = [$this->user];
- $this->setMapperResult($sql, $params, $this->rows, $this->limit, $this->offset);
+ $sql = 'AND `items`.`id` > ? ';
+ $sql = $this->makeSelectQueryStatus($sql, $this->status);
+ $params = array($this->user, $this->offset);
+ $this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAll($this->limit,
$this->offset, $this->status, true, $this->user);
@@ -289,6 +320,19 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
}
+ public function testFindAllOffsetZero(){
+ $sql = $this->makeSelectQueryStatus('', $this->status);
+ $params = array($this->user);
+ $this->setMapperResult($sql, $params, $this->rows);
+ $result = $this->mapper->findAll($this->limit,
+ 0, $this->status, false, $this->user);
+
+ $this->assertEquals($this->items, $result);
+ }
+
+
+
+
public function testFindByGuidHash(){
$hash = md5('test');
$feedId = 3;
@@ -296,7 +340,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `items`.`guid_hash` = ? ' .
'AND `feeds`.`id` = ? ');
- $this->setMapperResult($sql, [$this->userId, $hash, $feedId], $this->row);
+ $this->setMapperResult($sql, array($this->userId, $hash, $feedId), $this->row);
$result = $this->mapper->findByGuidHash($hash, $feedId, $this->userId);
$this->assertEquals($this->items[0], $result);
@@ -315,8 +359,8 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'HAVING COUNT(*) > ?';
$threshold = 10;
- $rows = [['feed_id' => 30, 'size' => 9]];
- $params = [$status, $threshold];
+ $rows = array(array('feed_id' => 30, 'size' => 9));
+ $params = array($status, $threshold);
$this->setMapperResult($sql, $params, $rows);
$this->mapper->deleteReadOlderThanThreshold($threshold);
@@ -337,18 +381,18 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {