Merge lp:~dano6/podbird/podbird into lp:podbird

Proposed by Daniel Kutka
Status: Merged
Merged at revision: 219
Proposed branch: lp:~dano6/podbird/podbird
Merge into: lp:podbird
Diff against target: 57 lines (+13/-2)
2 files modified
app/podcasts.js (+7/-2)
app/ui/EpisodesPage.qml (+6/-0)
To merge this branch: bzr merge lp:~dano6/podbird/podbird
Reviewer Review Type Date Requested Status
Michael Sheldon Approve
Review via email: mp+403254@code.launchpad.net

Commit message

Signifcantly improve time to update episodes

Description of the change

This should noticeably improve refreshing times, and maybe fix unability to refresh some podcasts.
There is changed logic, that it checks episodes added only certain time before last refresh.
But if you open some podcast from podcast list and than pull to refresh, it would refresh all episodes from that podcast.
Refresh time used to take so long because every episode pulled from xml (sometimes >1000) was searched in sql database (often >1000 lines)

To post a comment you must log in.
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Merged, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/podcasts.js'
2--- app/podcasts.js 2020-07-08 19:32:20 +0000
3+++ app/podcasts.js 2021-05-25 09:57:31 +0000
4@@ -184,7 +184,7 @@
5 var db = Podcasts.init();
6 db.transaction(function(tx) {
7 var rs = tx.executeSql("SELECT rowid, feed FROM Podcast");
8- tx.executeSql("UPDATE Podcast SET lastupdate=CURRENT_TIMESTAMP");
9+ var rs_timestamp = tx.executeSql("SELECT lastupdate FROM Podcast");
10 var xhr = [];
11 var xhrComplete = [];
12 for(var i = 0; i < rs.rows.length; i++) {
13@@ -236,7 +236,8 @@
14 if (!track.hasOwnProperty("guid")) {
15 track['guid'] = track.audiourl;
16 }
17-
18+ //do not check every episode in database, just ~11.5 days before last update
19+ if(new Date(rs_timestamp.rows.item(i).lastupdate).getTime()<(track['published']+1000000000))
20 db.transaction(function(tx2) {
21 var ers = tx2.executeSql("SELECT rowid FROM Episode WHERE guid=?", [track.guid]);
22 if (ers.rows.length === 0) {
23@@ -257,6 +258,7 @@
24 }
25 }
26 } catch (error) {
27+ console.log("[LOG]: Response: " + xhr[i].response)
28 console.log("[WARNING]: Failed to parse " + rs.rows.item(i).feed + ": " + error);
29 }
30 }
31@@ -268,6 +270,9 @@
32 }
33 }
34 if(allComplete) {
35+ db.transaction(function(tx) {
36+ tx.executeSql("UPDATE Podcast SET lastupdate=CURRENT_TIMESTAMP");
37+ })
38 console.log("[LOG]: Finished checking for new episodes..")
39 podbird.settings.lastUpdate = new Date();
40 refreshModel();
41
42=== modified file 'app/ui/EpisodesPage.qml'
43--- app/ui/EpisodesPage.qml 2021-01-12 21:16:11 +0000
44+++ app/ui/EpisodesPage.qml 2021-05-25 09:57:31 +0000
45@@ -750,6 +750,12 @@
46 }
47
48 function updateEpisodesDatabase() {
49+ var db = Podcasts.init();
50+ db.transaction(function (tx) {
51+ //refresh all episodes for this podcast, do not care about last update
52+ var rs = tx.executeSql("UPDATE Podcast SET lastupdate=0 WHERE rowid=?", [episodeId]);
53+ });
54+
55 episodesUpdating = true;
56 Podcasts.updateEpisodes(refreshModel)
57 }

Subscribers

People subscribed via source and target branches

to status/vote changes: