Merge branch 'master' into circular

# By ojiikun (3) and others
# Via Samuel Clay (3) and ojiikun (1)
* master:
  Upping ulimit file descriptor limits.
  README.md typo fixes
  newline at end of readme
  Fix duplicate appearance of All Stories heading.
  Revert "Fix NPE on login."
  Fix NPE on login.
This commit is contained in:
Samuel Clay 2013-04-30 10:28:45 -07:00
commit 1024db2295
4 changed files with 36 additions and 40 deletions

View file

@ -9,7 +9,7 @@
## Features
1. Shows the original site (you have to see it to believe it)
1. Shows the original site (you have to see it to believe it).
2. Hides stories you don't want to read based on tags, keywords, authors, etc.
3. Highlights stories you want to read, based on the same criteria.
@ -43,7 +43,7 @@
#### Relational Database (MySQL, PostgreSQL)
You will want to have your database setup before you begin installation. Fabric can install
You will want to have your database set up before you begin installation. Fabric can install
both PostgreSQL and MongoDB for you, but only on Ubuntu. Mac OS X users will want to have
MySQL or PostgreSQL already installed. You can [download MySQL](http://dev.mysql.com/downloads/mysql/)
or [download PostgreSQL](http://www.postgresql.org/download/). Additionally,
@ -165,7 +165,7 @@ these after the installation below.
### Installing on Linux / Ubuntu
If you are on Ubuntu, you can simple use [Fabric](http://docs.fabfile.org/) to install
If you are on Ubuntu, you can simply use [Fabric](http://docs.fabfile.org/) to install
NewsBlur and its many components. NewsBlur is designed to run on three separate servers:
an app server, a db server, and assorted task servers. To install everything on a single
machine, read through `fabfile.py` and setup all three servers without repeating the
@ -249,4 +249,4 @@ reader, and feed importer. To run the test suite:
## License
NewsBlur is licensed under the MIT License. (See LICENSE)
NewsBlur is licensed under the MIT License. (See LICENSE)

10
fabfile.py vendored
View file

@ -561,13 +561,13 @@ def setup_ulimit():
sudo('mv /etc/security/limits.conf /etc/security/limits.conf.bak', pty=False)
sudo('touch /etc/security/limits.conf', pty=False)
sudo('chmod 666 /etc/security/limits.conf', pty=False)
run('echo "root soft nofile 10000" >> /etc/security/limits.conf', pty=False)
run('echo "root hard nofile 10000" >> /etc/security/limits.conf', pty=False)
run('echo "* soft nofile 10000" >> /etc/security/limits.conf', pty=False)
run('echo "* hard nofile 10000" >> /etc/security/limits.conf', pty=False)
run('echo "root soft nofile 100000" >> /etc/security/limits.conf', pty=False)
run('echo "root hard nofile 100000" >> /etc/security/limits.conf', pty=False)
run('echo "* soft nofile 100000" >> /etc/security/limits.conf', pty=False)
run('echo "* hard nofile 100090" >> /etc/security/limits.conf', pty=False)
sudo('chmod 644 /etc/security/limits.conf', pty=False)
sudo('chmod 666 /etc/sysctl.conf', pty=False)
run('echo "fs.file-max = 10000" >> /etc/sysctl.conf', pty=False)
run('echo "fs.file-max = 100000" >> /etc/sysctl.conf', pty=False)
sudo('chmod 644 /etc/sysctl.conf', pty=False)
sudo('sysctl -p')

View file

@ -136,20 +136,6 @@ public class DatabaseConstants {
FOLDER_TABLE + "." + FOLDER_ID, FOLDER_TABLE + "." + FOLDER_NAME, " SUM(" + FEED_POSITIVE_COUNT + ") AS " + SUM_POS, " SUM(" + FEED_NEUTRAL_COUNT + ") AS " + SUM_NEUT, " SUM(" + FEED_NEGATIVE_COUNT + ") AS " + SUM_NEG
};
// this union clause lets folder queries also select the "root" folder that should appear whether or not
// it has unread stories. Note that this goes *before* the normal ALL_FOLDERS select statement. The zero-valued
// pseudo-columns are safe because said columns are ignored for the root folder. This is necessary because the
// joins used in order to fetch folders by unread count are all inner joins, and sqlite does not support
// full outer joins.
public static final String FOLDER_UNION_ROOT = "SELECT " +
FOLDER_ID + ", " +
FOLDER_NAME +
", 0 AS " + SUM_POS +
", 0 AS " + SUM_NEUT +
", 0 AS " + SUM_NEG +
" FROM " + FOLDER_TABLE +
" WHERE " + FOLDER_NAME + "='" + AppConstants.ROOT_FOLDER + "' UNION ";
private static final String FOLDER_INTELLIGENCE_ALL = " HAVING SUM(" + DatabaseConstants.FEED_NEGATIVE_COUNT + " + " + DatabaseConstants.FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.FEED_POSITIVE_COUNT + ") >= 0";
private static final String FOLDER_INTELLIGENCE_SOME = " HAVING SUM(" + DatabaseConstants.FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0";
private static final String FOLDER_INTELLIGENCE_BEST = " HAVING SUM(" + DatabaseConstants.FEED_POSITIVE_COUNT + ") > 0";

View file

@ -439,26 +439,36 @@ public class FeedProvider extends ContentProvider {
// Querying for all folders with unread items
case ALL_FOLDERS:
// Note the extra special pre-select UNION clause here! Due to an undocumented feature/bug in sqlite,
// if the two sides of the union are reversed, the result columns are incorrectly prefixed.
String folderQuery = DatabaseConstants.FOLDER_UNION_ROOT +
"SELECT " + TextUtils.join(",", DatabaseConstants.FOLDER_COLUMNS) + " FROM " + DatabaseConstants.FEED_FOLDER_MAP_TABLE +
" INNER JOIN " + DatabaseConstants.FOLDER_TABLE +
" ON " + DatabaseConstants.FEED_FOLDER_MAP_TABLE + "." + DatabaseConstants.FEED_FOLDER_FOLDER_NAME + " = " + DatabaseConstants.FOLDER_TABLE + "." + DatabaseConstants.FOLDER_NAME +
" INNER JOIN " + DatabaseConstants.FEED_TABLE +
" ON " + DatabaseConstants.FEED_TABLE + "." + DatabaseConstants.FEED_ID + " = " + DatabaseConstants.FEED_FOLDER_MAP_TABLE + "." + DatabaseConstants.FEED_FOLDER_FEED_ID +
" GROUP BY " + DatabaseConstants.FOLDER_TABLE + "." + DatabaseConstants.FOLDER_NAME;
// Of note about the following query:
// 1) the union clause lets ALL_FOLDER queries also select the "root" folder that appears in the UI whether
// or not it has unread stories in it.
// 2) the root folder is excluded from the final join so as not to create a duplicate root folder
// 3) values of the pos/neut/neg columns for the root folder are ignored by the UI
// 4) we use a union rather than a full outer join because sqlite doesn't support the latter
// 5) the order of the left and right sides of the union are important: due to an undocumented feature/bug in sqlite,
// if the two sides of the union are reversed, the result columns are incorrectly prefixed.
String folderQuery = "SELECT " + DatabaseConstants.FOLDER_ID + ", " + DatabaseConstants.FOLDER_NAME + ", 0 AS " + DatabaseConstants.SUM_POS + ", 0 AS " + DatabaseConstants.SUM_NEUT + ", 0 AS " + DatabaseConstants.SUM_NEG +
" FROM " + DatabaseConstants.FOLDER_TABLE +
" WHERE " + DatabaseConstants.FOLDER_NAME + "='" + AppConstants.ROOT_FOLDER + "' UNION" +
" SELECT " + TextUtils.join(",", DatabaseConstants.FOLDER_COLUMNS) +
" FROM " + DatabaseConstants.FEED_FOLDER_MAP_TABLE +
" INNER JOIN " + DatabaseConstants.FOLDER_TABLE +
" ON " + DatabaseConstants.FEED_FOLDER_MAP_TABLE + "." + DatabaseConstants.FEED_FOLDER_FOLDER_NAME + " = " + DatabaseConstants.FOLDER_TABLE + "." + DatabaseConstants.FOLDER_NAME +
" INNER JOIN " + DatabaseConstants.FEED_TABLE +
" ON " + DatabaseConstants.FEED_TABLE + "." + DatabaseConstants.FEED_ID + " = " + DatabaseConstants.FEED_FOLDER_MAP_TABLE + "." + DatabaseConstants.FEED_FOLDER_FEED_ID +
" WHERE NOT " + DatabaseConstants.FOLDER_NAME + "='" + AppConstants.ROOT_FOLDER + "'" +
" GROUP BY " + DatabaseConstants.FOLDER_TABLE + "." + DatabaseConstants.FOLDER_NAME;
StringBuilder folderBuilder = new StringBuilder();
folderBuilder.append(folderQuery);
if (selectionArgs != null && selectionArgs.length > 0) {
StringBuilder folderBuilder = new StringBuilder();
folderBuilder.append(folderQuery);
if (selectionArgs != null && selectionArgs.length > 0) {
// TODO: by not iterating over the selectionArgs array, this method wildly breaks the contract of the query() method and
// will almost certainly confuse callers eventually
folderBuilder.append(selectionArgs[0]);
}
folderBuilder.append(" ORDER BY ");
folderBuilder.append(DatabaseConstants.FOLDER_TABLE + "." + DatabaseConstants.FOLDER_NAME + " COLLATE NOCASE");
return db.rawQuery(folderBuilder.toString(), null);
folderBuilder.append(selectionArgs[0]);
}
folderBuilder.append(" ORDER BY ");
folderBuilder.append(DatabaseConstants.FOLDER_TABLE + "." + DatabaseConstants.FOLDER_NAME + " COLLATE NOCASE");
return db.rawQuery(folderBuilder.toString(), null);
case OFFLINE_UPDATES:
return db.query(DatabaseConstants.UPDATE_TABLE, null, null, null, null, null, null);
case ALL_SOCIAL_FEEDS: