Merge lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed into lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk
- database-bug-fixed
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Roman Shchekin |
Approved revision: | 16 |
Merged at revision: | 14 |
Proposed branch: | lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed |
Merge into: | lp:~ubuntu-shorts-dev/ubuntu-rssreader-app/trunk |
Diff against target: |
100 lines (+52/-8) 1 file modified
databasemodule_v2.js (+52/-8) |
To merge this branch: | bzr merge lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Roman Shchekin | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+170257@code.launchpad.net |
Commit message
bugs fixed, especially add a function "addArticles" to avoid the hard drive performance issue
Description of the change
bugs fixed, especially add a function "addArticles" to avoid the hard drive performance issue
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
Roman Shchekin (mrqtros) wrote : | # |
Joey, I found some issues in your code, I will explain them later, when I'll have access to PC.
But in the same time I found good solutions, like json.stringify and so on. We must merge our implementations of addArticles to get best one.
19.06.13 11:52 Joey Chan написал(а):
Joey Chan has proposed merging lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed into lp:ubuntu-rssreader-app.
Commit message:
bugs fixed, especially add a function "addArticles" to avoid the hard drive performance issue
Requested reviews:
Ubuntu RSS Feed Reader Developers (ubuntu-
For more details, see:
https:/
bugs fixed, especially add a function "addArticles" to avoid the hard drive performance issue
--
https:/
Your team Ubuntu RSS Feed Reader Developers is requested to review the proposed merge of lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed into lp:ubuntu-rssreader-app.
Joey Chan (qqworini) wrote : | # |
Good, wait for your further email
2013/6/19 Roman Shchekin <email address hidden>
> Joey, I found some issues in your code, I will explain them later, when
> I'll have access to PC.
>
> But in the same time I found good solutions, like json.stringify and so
> on. We must merge our implementations of addArticles to get best one.
>
>
> 19.06.13 11:52 Joey Chan написал(а):
>
> Joey Chan has proposed merging
> lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed into
> lp:ubuntu-rssreader-app.
>
>
> Commit message:
> bugs fixed, especially add a function "addArticles" to avoid the hard
> drive performance issue
>
>
> Requested reviews:
> Ubuntu RSS Feed Reader Developers (ubuntu-
>
>
> For more details, see:
>
>
> https:/
>
>
> bugs fixed, especially add a function "addArticles" to avoid the hard
> drive performance issue
>
> --
>
> https:/
>
> Your team Ubuntu RSS Feed Reader Developers is requested to review the
> proposed merge of lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed into
> lp:ubuntu-rssreader-app.
>
>
>
>
>
> https:/
> You are the owner of lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed.
>
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:15
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:16
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Roman Shchekin (mrqtros) wrote : | # |
Joey, sry for late answer!
Look this line
if (params.isAll || params == undefined) // or miss params
second condition will never return true. Swap conditions.
Cycle in function addArticles contains a lot of additional temp variables.
I think we must use minimum of them.
But if performance satisfied you, code is ok :)
And last advice - for back compatibility save function addArticle :) Mb it
will be helpful for us later!
BR,
Roman.
2013/6/19 Joey Chan <email address hidden>
> Good, wait for your further email
>
>
> 2013/6/19 Roman Shchekin <email address hidden>
>
> > Joey, I found some issues in your code, I will explain them later, when
> > I'll have access to PC.
> >
> > But in the same time I found good solutions, like json.stringify and so
> > on. We must merge our implementations of addArticles to get best one.
> >
> >
> > 19.06.13 11:52 Joey Chan написал(а):
> >
> > Joey Chan has proposed merging
> > lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed into
> > lp:ubuntu-rssreader-app.
> >
> >
> > Commit message:
> > bugs fixed, especially add a function "addArticles" to avoid the hard
> > drive performance issue
> >
> >
> > Requested reviews:
> > Ubuntu RSS Feed Reader Developers (ubuntu-
> >
> >
> > For more details, see:
> >
> >
> >
> https:/
> >
> >
> > bugs fixed, especially add a function "addArticles" to avoid the hard
> > drive performance issue
> >
> > --
> >
> >
> https:/
> >
> > Your team Ubuntu RSS Feed Reader Developers is requested to review the
> > proposed merge of lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed
> into
> > lp:ubuntu-rssreader-app.
> >
> >
> >
> >
> >
> >
> https:/
> > You are the owner of
> lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed.
> >
>
> --
>
> https:/
> Your team Ubuntu RSS Feed Reader Developers is requested to review the
> proposed merge of lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed into
> lp:ubuntu-rssreader-app.
>
Joey Chan (qqworini) wrote : | # |
Hi Roman,
1. for "params.isAll"
U R right, so I changed them as below codes
if (params == undefined) // in case someone miss the parameters
else if (params.isAll)
2. for "addArticles" function
I use those temp variables in order to prevent the js's 'undefined' value stopping the whole function process. And performance so far so good :)
3. for keeping "addArticle" function
I agree with u, I already kept this function in the source code
> Joey, sry for late answer!
>
> Look this line
>
> if (params.isAll || params == undefined) // or miss params
>
> second condition will never return true. Swap conditions.
> Cycle in function addArticles contains a lot of additional temp variables.
> I think we must use minimum of them.
> But if performance satisfied you, code is ok :)
>
> And last advice - for back compatibility save function addArticle :) Mb it
> will be helpful for us later!
>
> BR,
> Roman.
>
>
> 2013/6/19 Joey Chan <email address hidden>
>
> > Good, wait for your further email
> >
> >
> > 2013/6/19 Roman Shchekin <email address hidden>
> >
> > > Joey, I found some issues in your code, I will explain them later, when
> > > I'll have access to PC.
> > >
> > > But in the same time I found good solutions, like json.stringify and so
> > > on. We must merge our implementations of addArticles to get best one.
> > >
> > >
> > > 19.06.13 11:52 Joey Chan написал(а):
> > >
> > > Joey Chan has proposed merging
> > > lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed into
> > > lp:ubuntu-rssreader-app.
> > >
> > >
> > > Commit message:
> > > bugs fixed, especially add a function "addArticles" to avoid the hard
> > > drive performance issue
> > >
> > >
> > > Requested reviews:
> > > Ubuntu RSS Feed Reader Developers (ubuntu-
> > >
> > >
> > > For more details, see:
> > >
> > >
> > >
> > https:/
> fixed/+merge/170257
> > >
> > >
> > > bugs fixed, especially add a function "addArticles" to avoid the hard
> > > drive performance issue
> > >
> > > --
> > >
> > >
> > https:/
> fixed/+merge/170257
> > >
> > > Your team Ubuntu RSS Feed Reader Developers is requested to review the
> > > proposed merge of lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed
> > into
> > > lp:ubuntu-rssreader-app.
> > >
> > >
> > >
> > >
> > >
> > >
> > https:/
> fixed/+merge/170257
> > > You are the owner of
> > lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed.
> > >
> >
> > --
> >
> > https:/
> fixed/+merge/170257
> > Your team Ubuntu RSS Feed Reader Developers is requested to review the
> > proposed merge of lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed into
> > lp:ubuntu-rssreader-app.
> >
Roman Shchekin (mrqtros) wrote : | # |
That's cool, so do you need to request merge of new version?
2013/6/20 Joey Chan <email address hidden>
> Hi Roman,
>
> 1. for "params.isAll"
> U R right, so I changed them as below codes
> if (params == undefined) // in case someone miss the parameters
> xxxxxxxxxxxx ;
> else if (params.isAll)
> xxxxxxxxxxxx ;
>
> 2. for "addArticles" function
> I use those temp variables in order to prevent the js's 'undefined' value
> stopping the whole function process. And performance so far so good :)
>
> 3. for keeping "addArticle" function
> I agree with u, I already kept this function in the source code
>
> > Joey, sry for late answer!
> >
> > Look this line
> >
> > if (params.isAll || params == undefined) // or miss params
> >
> > second condition will never return true. Swap conditions.
> > Cycle in function addArticles contains a lot of additional temp
> variables.
> > I think we must use minimum of them.
> > But if performance satisfied you, code is ok :)
> >
> > And last advice - for back compatibility save function addArticle :) Mb
> it
> > will be helpful for us later!
> >
> > BR,
> > Roman.
> >
> >
> > 2013/6/19 Joey Chan <email address hidden>
> >
> > > Good, wait for your further email
> > >
> > >
> > > 2013/6/19 Roman Shchekin <email address hidden>
> > >
> > > > Joey, I found some issues in your code, I will explain them later,
> when
> > > > I'll have access to PC.
> > > >
> > > > But in the same time I found good solutions, like json.stringify and
> so
> > > > on. We must merge our implementations of addArticles to get best one.
> > > >
> > > >
> > > > 19.06.13 11:52 Joey Chan написал(а):
> > > >
> > > > Joey Chan has proposed merging
> > > > lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed into
> > > > lp:ubuntu-rssreader-app.
> > > >
> > > >
> > > > Commit message:
> > > > bugs fixed, especially add a function "addArticles" to avoid the hard
> > > > drive performance issue
> > > >
> > > >
> > > > Requested reviews:
> > > > Ubuntu RSS Feed Reader Developers (ubuntu-
> > > >
> > > >
> > > > For more details, see:
> > > >
> > > >
> > > >
> > >
> https:/
> > fixed/+merge/170257
> > > >
> > > >
> > > > bugs fixed, especially add a function "addArticles" to avoid the hard
> > > > drive performance issue
> > > >
> > > > --
> > > >
> > > >
> > >
> https:/
> > fixed/+merge/170257
> > > >
> > > > Your team Ubuntu RSS Feed Reader Developers is requested to review
> the
> > > > proposed merge of
> lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed
> > > into
> > > > lp:ubuntu-rssreader-app.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> https:/
> > fixed/+merge/170257
> > > > You are the owner of
> > > lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed.
> > > >
> > >
> > > --
> > >
> > >
> https:/
> > fixed/+merge/170257
> > > Your team Ubuntu RSS Feed Reader Developers is requested to review the
> > > proposed merge of lp:~qqworini/ubuntu-rssreader-...
Joey Chan (qqworini) wrote : | # |
yes pls :) just approve it
> That's cool, so do you need to request merge of new version?
>
>
> 2013/6/20 Joey Chan <email address hidden>
>
> > Hi Roman,
> >
> > 1. for "params.isAll"
> > U R right, so I changed them as below codes
> > if (params == undefined) // in case someone miss the parameters
> > xxxxxxxxxxxx ;
> > else if (params.isAll)
> > xxxxxxxxxxxx ;
> >
> > 2. for "addArticles" function
> > I use those temp variables in order to prevent the js's 'undefined' value
> > stopping the whole function process. And performance so far so good :)
> >
> > 3. for keeping "addArticle" function
> > I agree with u, I already kept this function in the source code
> >
> > > Joey, sry for late answer!
> > >
> > > Look this line
> > >
> > > if (params.isAll || params == undefined) // or miss params
> > >
> > > second condition will never return true. Swap conditions.
> > > Cycle in function addArticles contains a lot of additional temp
> > variables.
> > > I think we must use minimum of them.
> > > But if performance satisfied you, code is ok :)
> > >
> > > And last advice - for back compatibility save function addArticle :) Mb
> > it
> > > will be helpful for us later!
> > >
> > > BR,
> > > Roman.
> > >
> > >
> > > 2013/6/19 Joey Chan <email address hidden>
> > >
> > > > Good, wait for your further email
> > > >
> > > >
> > > > 2013/6/19 Roman Shchekin <email address hidden>
> > > >
> > > > > Joey, I found some issues in your code, I will explain them later,
> > when
> > > > > I'll have access to PC.
> > > > >
> > > > > But in the same time I found good solutions, like json.stringify and
> > so
> > > > > on. We must merge our implementations of addArticles to get best one.
> > > > >
> > > > >
> > > > > 19.06.13 11:52 Joey Chan написал(а):
> > > > >
> > > > > Joey Chan has proposed merging
> > > > > lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed into
> > > > > lp:ubuntu-rssreader-app.
> > > > >
> > > > >
> > > > > Commit message:
> > > > > bugs fixed, especially add a function "addArticles" to avoid the hard
> > > > > drive performance issue
> > > > >
> > > > >
> > > > > Requested reviews:
> > > > > Ubuntu RSS Feed Reader Developers (ubuntu-
> > > > >
> > > > >
> > > > > For more details, see:
> > > > >
> > > > >
> > > > >
> > > >
> > https:/
> > > fixed/+merge/170257
> > > > >
> > > > >
> > > > > bugs fixed, especially add a function "addArticles" to avoid the hard
> > > > > drive performance issue
> > > > >
> > > > > --
> > > > >
> > > > >
> > > >
> > https:/
> > > fixed/+merge/170257
> > > > >
> > > > > Your team Ubuntu RSS Feed Reader Developers is requested to review
> > the
> > > > > proposed merge of
> > lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed
> > > > into
> > > > > lp:ubuntu-rssreader-app.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > https:/
> > > fixed/+merge/170257
> > > > > You are the owner of
> > > > lp:~qqworini/ubuntu-rssreader-app/database-bug-fixed.
> > > > >
> > >...
Roman Shchekin (mrqtros) : | # |
Preview Diff
1 | === modified file 'databasemodule_v2.js' |
2 | --- databasemodule_v2.js 2013-06-15 16:01:24 +0000 |
3 | +++ databasemodule_v2.js 2013-06-19 14:52:27 +0000 |
4 | @@ -58,7 +58,7 @@ |
5 | // // ... |
6 | // case "all": // Check all tables existing. |
7 | transaction.executeSql('PRAGMA foreign_keys = ON;') // enable foreign key support |
8 | - transaction.executeSql("CREATE TABLE IF NOT EXISTS feed (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,source VARCHAR(99) NULL,title VARCHAR(99) NULL,link VARCHAR(99) NULL, description TEXT NULL, status char(1) NULL DEFAULT '0', pubdate INTEGER NULL,image VARCHAR(99) NULL);") // <- pubDate? I saw only lastBuildDate |
9 | + transaction.executeSql("CREATE TABLE IF NOT EXISTS feed (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,source VARCHAR(99) NULL,title VARCHAR(99) NULL,link VARCHAR(99) NULL, description TEXT NULL, status char(1) NULL DEFAULT '0', pubdate INTEGER NULL,image VARCHAR(99) NULL, count INTEGER NULL DEFAULT 0);") // add "count", count user click |
10 | transaction.executeSql("CREATE TABLE IF NOT EXISTS tag (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,name VARCHAR(99) NOT NULL UNIQUE );") |
11 | transaction.executeSql("CREATE TABLE IF NOT EXISTS feed_tag (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,feed_id INTEGER NULL,tag_id INTEGER NULL,FOREIGN KEY(feed_id) REFERENCES feed(id) on delete cascade);") |
12 | transaction.executeSql("CREATE TABLE IF NOT EXISTS article ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, title VARCHAR(99) NULL, content TEXT NULL, link VARCHAR(99) NULL, description TEXT NULL, pubdate INTEGER NULL, status char(1) NULL DEFAULT '0', favourite char(1) NULL DEFAULT '0', image VARCHAR(99) NULL, guid VARCHAR(99) NULL, feed_id INTEGER NULL,count INTEGER NULL DEFAULT 0);") |
13 | @@ -153,14 +153,14 @@ |
14 | return dbResult |
15 | } |
16 | |
17 | -function updateFeedByXml(id, link, description, title) // from xml file |
18 | +function updateFeedByXml(id, link, description, title, pubdate) // from xml file |
19 | { |
20 | var db = openStdDataBase() |
21 | var dbResult |
22 | db.transaction(function (tx) { |
23 | // ensureFeedTableExists(tx) |
24 | - dbResult = tx.executeSql('UPDATE feed SET link=?, description=?, title=? WHERE id=?', |
25 | - [link, description, title, id]) |
26 | + dbResult = tx.executeSql('UPDATE feed SET link=?, description=?, title=?, pubdate=? WHERE id=?', |
27 | + [link, description, title, pubdate, id]) |
28 | console.log("feed updateFeedByXml, AFFECTED ROWS: ", dbResult.rowsAffected) |
29 | } |
30 | ) |
31 | @@ -233,14 +233,17 @@ |
32 | // return dbResult; |
33 | //} |
34 | |
35 | -function loadArticles(params) { |
36 | +function loadArticles(params) // params = {"isAll": true/false, "feedId": id} |
37 | +{ |
38 | var db = openStdDataBase() |
39 | var dbResult |
40 | |
41 | db.transaction(function(tx) { |
42 | - if (params.isAll) |
43 | - dbResult = tx.executeSql('SELECT * FROM article') |
44 | - else dbResult = tx.executeSql('SELECT * FROM article WHERE feed_id = ?', [params.feedId]) |
45 | + if (params == undefined) // miss params |
46 | + dbResult = tx.executeSql('SELECT article.*, feed.title as feed_name FROM article inner join feed on article.feed_id = feed.id ') |
47 | + else if (params.isAll) |
48 | + dbResult = tx.executeSql('SELECT article.*, feed.title as feed_name FROM article inner join feed on article.feed_id = feed.id') |
49 | + else dbResult = tx.executeSql('SELECT article.*, feed.title as feed_name FROM article inner join feed on article.feed_id = feed.id WHERE article.feed_id = ?', [params.feedId]) |
50 | console.log("loadArticles, SELECTED ROWS", dbResult.rows.length) |
51 | } |
52 | ) |
53 | @@ -269,6 +272,47 @@ |
54 | return dbResult; |
55 | } |
56 | |
57 | +/* |
58 | + this function is for avoiding hard drive performance issue, |
59 | + pass model and feed id as parameters to this function, it will automaticly insert all the articles into database |
60 | + */ |
61 | +function addArticles(model, feed_id) |
62 | +{ |
63 | + var dbResult |
64 | + |
65 | + var db = openStdDataBase() |
66 | + db.transaction(function (tx) { |
67 | +// ensureFeedTableExists(tx) |
68 | + |
69 | + var article; |
70 | + for (var i = 0; i < model.count; i++) { |
71 | + |
72 | + article = model.get(i) |
73 | + var title = article.title == undefined ? "" : article.title |
74 | + var guid = article.guid == undefined ? Qt.md5(title) : article.guid |
75 | + var link = article.link == undefined ? "" : article.link |
76 | + var pubDate = article.pubDate == undefined ? "" : article.pubDate |
77 | + var description = article.description == undefined ? "" : article.description |
78 | + var content = article.content == undefined ? "" : article.content |
79 | + |
80 | + /* Check uniqueness. |
81 | + */ |
82 | + dbResult = tx.executeSql("SELECT * FROM article WHERE guid=? AND feed_id=?", [guid, feed_id]) |
83 | + if (dbResult.rows.length > 0) { |
84 | + console.log("Database, add article: already exist article with source: ", guid) |
85 | + continue; |
86 | + } |
87 | + dbResult = tx.executeSql('INSERT INTO article (title, content, link, description, pubdate, guid, feed_id) VALUES(?, ?, ?, ?, ?, ?, ?)', |
88 | + [title, content, link, description, pubDate, guid, feed_id]) |
89 | + console.log("article INSERT ID: ", JSON.stringify(dbResult) ) |
90 | + } |
91 | + |
92 | +// console.log("article INSERT ID: ", JSON.stringify(dbResult) ) |
93 | + } |
94 | + ) |
95 | + return dbResult; |
96 | +} |
97 | + |
98 | // update |
99 | function updateArticleStatus(id, status) |
100 | { |
PASSED: Continuous integration, rev:14 91.189. 93.125: 8080/job/ ubuntu- rssreader- app-ci/ 6/ 91.189. 93.125: 8080/job/ ubuntu- rssreader- app-quantal- amd64-ci/ 3 91.189. 93.125: 8080/job/ ubuntu- rssreader- app-raring- amd64-ci/ 6
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.125: 8080/job/ ubuntu- rssreader- app-ci/ 6/rebuild
http://