aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2010-11-04 22:24:05 +0100
committercedricbonhomme <devnull@localhost>2010-11-04 22:24:05 +0100
commitf6477cfceeb7fa9400ba76a0c9f22c7703c2d7a5 (patch)
treeeeff9a799e50028fa7f8021b14fbaf034878d4ee
parentMajor improvement of the performance (concerning the management page). (diff)
downloadnewspipe-f6477cfceeb7fa9400ba76a0c9f22c7703c2d7a5.tar.gz
newspipe-f6477cfceeb7fa9400ba76a0c9f22c7703c2d7a5.tar.bz2
newspipe-f6477cfceeb7fa9400ba76a0c9f22c7703c2d7a5.zip
Improvement of the performance (concerning the load of articles from data base in memory).
-rwxr-xr-xpyAggr3g470r.py6
-rwxr-xr-xutils.py17
2 files changed, 20 insertions, 3 deletions
diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py
index e8525526..be2e796c 100755
--- a/pyAggr3g470r.py
+++ b/pyAggr3g470r.py
@@ -1095,7 +1095,10 @@ class Root:
with the database.
Called when a changes in the database is detected.
"""
- self.articles, self.feeds = utils.load_feed()
+ self.articles, self.feeds, \
+ self.nb_articles, self.nb_unread_articles, \
+ self.nb_favorites, self.nb_mail_notifications = utils.load_feed()
+ """
self.nb_articles = sum([feed[0] for feed in self.feeds.values()])
self.nb_unread_articles = sum([feed[1] for feed in self.feeds.values()])
self.nb_mail_notifications = len([feed for feed in self.feeds.values() \
@@ -1103,6 +1106,7 @@ class Root:
self.nb_favorites = sum([len([article for article in self.articles[feed_id] \
if article[7] == "1"]) \
for feed_id in self.feeds.keys()])
+ """
if self.articles != {}:
print "Base (%s) loaded" % utils.sqlite_base
else:
diff --git a/utils.py b/utils.py
index c62e1237..4da2dd99 100755
--- a/utils.py
+++ b/utils.py
@@ -363,6 +363,11 @@ def load_feed():
tupleList = [(x[0].lower(), x) for x in list_of_feeds]
tupleList.sort(key=operator.itemgetter(0))
+ nb_articles = 0
+ nb_unread_articles = 0
+ nb_mail_notifications = 0
+ nb_favorites = 0
+
for feed in [x[1] for x in tupleList]:
list_of_articles = c.execute(\
"SELECT * FROM articles WHERE feed_link='" + \
@@ -392,6 +397,10 @@ def load_feed():
article[2], unescape(article[3]), \
article[4], language, article[6]]
+
+ nb_favorites = nb_favorites + int(article[6])
+
+
if feed_id not in articles:
try:
articles[feed_id] = blist([article_list])
@@ -407,8 +416,12 @@ def load_feed():
feed[3], feed[0], feed[2], feed[1] , feed[4]\
)
+ nb_articles += feeds[feed_id][0]
+ nb_unread_articles += feeds[feed_id][1]
+ nb_mail_notifications += int(feeds[feed_id][6])
+
c.close()
LOCKER.release()
- return (articles, feeds)
+ return (articles, feeds, nb_articles, nb_unread_articles, nb_favorites, nb_mail_notifications)
LOCKER.release()
- return (articles, feeds)
+ return (articles, feeds, nb_articles, nb_unread_articles, nb_favorites, nb_mail_notifications)
bgstack15