Merge lp:~nik90/podbird/3-auto-clean-episodes into lp:podbird

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Michael Sheldon
Approved revision: 50
Merged at revision: 38
Proposed branch: lp:~nik90/podbird/3-auto-clean-episodes
Merge into: lp:podbird
Prerequisite: lp:~nik90/podbird/2-add-button-feedback
Diff against target: 239 lines (+154/-31)
3 files modified
app/podbird.qml (+31/-0)
app/ui/SettingsTab.qml (+79/-28)
po/com.mikeasoft.podbird.pot (+44/-3)
To merge this branch: bzr merge lp:~nik90/podbird/3-auto-clean-episodes
Reviewer Review Type Date Requested Status
Michael Sheldon Approve
Review via email: mp+252523@code.launchpad.net

Commit message

Adds a settings option to auto-remove episodes older than a certain time period (based on their published date). The clean-up is done at app-startup once per day.

Description of the change

Adds a settings option to auto-remove episodes older than a certain time period (based on their published date). The clean-up is done at app-startup once per day.

Screenie: http://imgur.com/KjNdeP1

To post a comment you must log in.
48. By Nekhelesh Ramananthan

Set default retention days to never

49. By Nekhelesh Ramananthan

Fixed listitem height

50. By Nekhelesh Ramananthan

Merged prerequisite lp:~nik90/podbird/2-add-button-feedback

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Looks good :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'app/podbird.qml'
--- app/podbird.qml 2015-03-27 15:38:51 +0000
+++ app/podbird.qml 2015-03-27 15:38:51 +0000
@@ -45,6 +45,16 @@
45 downloader.cancel();45 downloader.cancel();
46 }46 }
4747
48 Component.onCompleted: {
49 var today = new Date()
50 // Only perform cleanup of old episodes once a day
51 if (Math.floor((today - settings.lastCheck)/86400000) >= 1 && settings.retentionDays !== -1) {
52 console.log("[LOG]: Starting cleanup of old episodes..")
53 cleanUp(today, settings.retentionDays)
54 settings.lastCheck = today
55 }
56 }
57
48 property string currentName58 property string currentName
49 property string currentArtist59 property string currentArtist
50 property string currentImage60 property string currentImage
@@ -61,6 +71,8 @@
61 property var settings: Settings {71 property var settings: Settings {
62 // Set "Light.qml" as the default theme72 // Set "Light.qml" as the default theme
63 property string themeName: "Light.qml"73 property string themeName: "Light.qml"
74 property int retentionDays: -1
75 property var lastCheck: new Date()
64 }76 }
6577
66 FileManager {78 FileManager {
@@ -175,4 +187,23 @@
175 }187 }
176 }188 }
177 }189 }
190
191 function cleanUp(today, retentionDays) {
192 var dayToMs = 86400000; //1 * 24 * 60 * 60 * 1000
193 var db = Podcasts.init()
194 db.transaction(function (tx) {
195 var rs = tx.executeSql("SELECT rowid, * FROM Podcast ORDER BY name ASC");
196 for(var i = 0; i < rs.rows.length; i++) {
197 var podcast = rs.rows.item(i);
198 var rs2 = tx.executeSql("SELECT rowid, * FROM Episode WHERE podcast=?", [rs.rows.item(i).rowid]);
199 for (var j=0; j< rs2.rows.length; j++) {
200 var diff = Math.floor((today - rs2.rows.item(j).published)/dayToMs)
201 if (rs2.rows.item(j).downloadedfile && diff > retentionDays) {
202 fileManager.deleteFile(rs2.rows.item(j).downloadedfile)
203 tx.executeSql("UPDATE Episode SET downloadedfile = NULL WHERE guid = ?", [rs2.rows.item(j).guid]);
204 }
205 }
206 }
207 });
208 }
178}209}
179210
=== modified file 'app/ui/SettingsTab.qml'
--- app/ui/SettingsTab.qml 2015-03-27 15:38:51 +0000
+++ app/ui/SettingsTab.qml 2015-03-27 15:38:51 +0000
@@ -30,35 +30,86 @@
3030
31 ListModel {31 ListModel {
32 id: themeModel32 id: themeModel
33 ListElement { name: "Light"; file: "Light.qml" }33 Component.onCompleted: initialize()
34 ListElement { name: "Dark"; file: "Dark.qml" }34 function initialize() {
35 }35 themeModel.append({ name: i18n.tr("Light"), file: "Light.qml" })
3636 themeModel.append({ name: i18n.tr("Dark"), file: "Dark.qml" })
37 ExpandableListItem {37 }
38 id: themeSetting38 }
3939
40 model: themeModel40 ListModel {
41 text: i18n.tr("Theme")41 id: cleanupModel
42 subText: podbird.settings.themeName.split(".qml")[0]42 Component.onCompleted: initialize()
4343 function initialize() {
44 delegate: ListItem.Standard {44 cleanupModel.append({ name: i18n.tr("Never"), value: -1 })
45 text: model.name45 cleanupModel.append({ name: i18n.tr("7 days"), value: 7 })
4646 cleanupModel.append({ name: i18n.tr("31 days"), value: 31 })
47 onClicked: {47 cleanupModel.append({ name: i18n.tr("90 days"), value: 90 })
48 var themeElement = model.file48 cleanupModel.append({ name: i18n.tr("180 days"), value: 180 })
49 podbird.settings.themeName = themeElement49 cleanupModel.append({ name: i18n.tr("360 days"), value: 360 })
50 podbird.themeManager.source = themeElement50 }
51 themeSetting.expanded = false51 }
52
53 Column {
54 id: settingsColumn
55
56 anchors.fill: parent
57
58 ExpandableListItem {
59 id: themeSetting
60
61 model: themeModel
62 text: i18n.tr("Theme")
63 subText: podbird.settings.themeName.split(".qml")[0]
64
65 delegate: ListItem.Standard {
66 text: model.name
67
68 onClicked: {
69 var themeElement = model.file
70 podbird.settings.themeName = themeElement
71 podbird.themeManager.source = themeElement
72 themeSetting.expanded = false
73 }
74
75 Icon {
76 width: units.gu(2)
77 height: width
78 name: "ok"
79 visible: podbird.settings.themeName === model.file
80 anchors.right: parent.right
81 anchors.rightMargin: units.gu(2)
82 anchors.verticalCenter: parent.verticalCenter
83 }
52 }84 }
5385 }
54 Icon {86
55 width: units.gu(2)87 ExpandableListItem {
56 height: width88 id: cleanupSetting
57 name: "ok"89
58 visible: podbird.settings.themeName === model.file90 listViewHeight: units.gu(36)
59 anchors.right: parent.right91 model: cleanupModel
60 anchors.rightMargin: units.gu(2)92 text: i18n.tr("Remove episodes older than")
61 anchors.verticalCenter: parent.verticalCenter93 subText: podbird.settings.retentionDays === -1 ? i18n.tr("Never")
94 : i18n.tr("%1 days").arg(podbird.settings.retentionDays)
95
96 delegate: ListItem.Standard {
97 text: model.name
98
99 onClicked: {
100 podbird.settings.retentionDays = model.value
101 cleanupSetting.expanded = false
102 }
103
104 Icon {
105 width: units.gu(2)
106 height: width
107 name: "ok"
108 visible: podbird.settings.retentionDays === model.value
109 anchors.right: parent.right
110 anchors.rightMargin: units.gu(2)
111 anchors.verticalCenter: parent.verticalCenter
112 }
62 }113 }
63 }114 }
64 }115 }
65116
=== modified file 'po/com.mikeasoft.podbird.pot'
--- po/com.mikeasoft.podbird.pot 2015-03-27 15:38:51 +0000
+++ po/com.mikeasoft.podbird.pot 2015-03-27 15:38:51 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: \n"9"Project-Id-Version: \n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2015-03-27 16:30+0100\n"11"POT-Creation-Date: 2015-03-27 16:34+0100\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -164,10 +164,51 @@
164msgid "Settings"164msgid "Settings"
165msgstr ""165msgstr ""
166166
167#: ../app/ui/SettingsTab.qml:41167#: ../app/ui/SettingsTab.qml:35
168msgid "Light"
169msgstr ""
170
171#: ../app/ui/SettingsTab.qml:36
172msgid "Dark"
173msgstr ""
174
175#: ../app/ui/SettingsTab.qml:44 ../app/ui/SettingsTab.qml:93
176msgid "Never"
177msgstr ""
178
179#: ../app/ui/SettingsTab.qml:45
180msgid "7 days"
181msgstr ""
182
183#: ../app/ui/SettingsTab.qml:46
184msgid "31 days"
185msgstr ""
186
187#: ../app/ui/SettingsTab.qml:47
188msgid "90 days"
189msgstr ""
190
191#: ../app/ui/SettingsTab.qml:48
192msgid "180 days"
193msgstr ""
194
195#: ../app/ui/SettingsTab.qml:49
196msgid "360 days"
197msgstr ""
198
199#: ../app/ui/SettingsTab.qml:62
168msgid "Theme"200msgid "Theme"
169msgstr ""201msgstr ""
170202
171#: /home/krnekhelesh/Documents/Ubuntu-Projects/MP-Reviews/builddir/build-2-add-button-feedback-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_14_10_utopic-Default/po/Podbird.desktop.in.h:1203#: ../app/ui/SettingsTab.qml:92
204msgid "Remove episodes older than"
205msgstr ""
206
207#: ../app/ui/SettingsTab.qml:94
208#, qt-format
209msgid "%1 days"
210msgstr ""
211
212#: /home/krnekhelesh/Documents/Ubuntu-Projects/MP-Reviews/builddir/build-3-auto-clean-episodes-UbuntuSDK_for_armhf_GCC_ubuntu_sdk_14_10_utopic-Default/po/Podbird.desktop.in.h:1
172msgid "Podbird"213msgid "Podbird"
173msgstr ""214msgstr ""

Subscribers

People subscribed via source and target branches