Skip to content

Commit

Permalink
DASH-216
Browse files Browse the repository at this point in the history
Added checks to see whether to expire particular kinds of links and whether to purge links.


git-svn-id: https://source.sakaiproject.org/svn/dashboard/trunk@313218 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
jimeng committed Apr 3, 2012
1 parent fdff541 commit 5ab3f2b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public interface DashboardConfig {
public static final String PROP_REMOVE_CALENDAR_ITEMS_AFTER_WEEKS = "PROP_REMOVE_CALENDAR_ITEMS_AFTER_WEEKS";
public static final String PROP_REMOVE_STARRED_CALENDAR_ITEMS_AFTER_WEEKS = "PROP_REMOVE_STARRED_CALENDAR_ITEMS_AFTER_WEEKS";
public static final String PROP_REMOVE_HIDDEN_CALENDAR_ITEMS_AFTER_WEEKS = "PROP_REMOVE_STARRED_CALENDAR_ITEMS_AFTER_WEEKS";
public static final String PROP_REMOVE_NEWS_ITEMS_WITH_NO_LINKS = "PROP_REMOVE_NEWS_ITEMS_WITH_NO_LINKS";
public static final String PROP_REMOVE_CALENDAR_ITEMS_WITH_NO_LINKS = "PROP_REMOVE_NEWS_ITEMS_WITH_NO_LINKS";

// horizon settings
public static final String PROP_DAYS_BETWEEN_HORIZ0N_UPDATES = "PROP_DAYS_BETWEEN_HORIZ0N_UPDATES";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1914,12 +1914,20 @@ protected void expireAndPurgeNewsItems() {
Integer weeksToExpireItems = dashboardConfig.getConfigValue(DashboardConfig.PROP_REMOVE_NEWS_ITEMS_AFTER_WEEKS, DEFAULT_NEWS_ITEM_EXPIRATION);
Integer weeksToExpireStarredItems = dashboardConfig.getConfigValue(DashboardConfig.PROP_REMOVE_STARRED_NEWS_ITEMS_AFTER_WEEKS, DEFAULT_NEWS_ITEM_EXPIRATION);
Integer weeksToExpireHiddenItems = dashboardConfig.getConfigValue(DashboardConfig.PROP_REMOVE_HIDDEN_NEWS_ITEMS_AFTER_WEEKS, DEFAULT_NEWS_ITEM_EXPIRATION);

expireNewsLinks(new Date(System.currentTimeMillis() - weeksToExpireItems.intValue() * ONE_WEEK_IN_MILLIS), false, false);
expireNewsLinks(new Date(System.currentTimeMillis() - weeksToExpireStarredItems.intValue() * ONE_WEEK_IN_MILLIS), false, false);
expireNewsLinks(new Date(System.currentTimeMillis() - weeksToExpireHiddenItems.intValue() * ONE_WEEK_IN_MILLIS), false, true);
purgeNewsItems();
Integer purgeItemsWithoutLinks = dashboardConfig.getConfigValue(DashboardConfig.PROP_REMOVE_NEWS_ITEMS_WITH_NO_LINKS, 0);

if(weeksToExpireItems.intValue() > 0) {
expireNewsLinks(new Date(System.currentTimeMillis() - weeksToExpireItems.intValue() * ONE_WEEK_IN_MILLIS), false, false);
}
if(weeksToExpireStarredItems.intValue() > 0) {
expireNewsLinks(new Date(System.currentTimeMillis() - weeksToExpireStarredItems.intValue() * ONE_WEEK_IN_MILLIS), false, false);
}
if(weeksToExpireHiddenItems.intValue() > 0) {
expireNewsLinks(new Date(System.currentTimeMillis() - weeksToExpireHiddenItems.intValue() * ONE_WEEK_IN_MILLIS), false, true);
}
if(purgeItemsWithoutLinks.intValue() > 0) {
purgeNewsItems();
}
}

private void purgeNewsItems() {
Expand All @@ -1935,11 +1943,20 @@ protected void expireAndPurgeCalendarItems() {
Integer weeksToExpireItems = dashboardConfig.getConfigValue(DashboardConfig.PROP_REMOVE_CALENDAR_ITEMS_AFTER_WEEKS, DEFAULT_CALENDAR_ITEM_EXPIRATION);
Integer weeksToExpireStarredItems = dashboardConfig.getConfigValue(DashboardConfig.PROP_REMOVE_STARRED_CALENDAR_ITEMS_AFTER_WEEKS, DEFAULT_CALENDAR_ITEM_EXPIRATION);
Integer weeksToExpireHiddenItems = dashboardConfig.getConfigValue(DashboardConfig.PROP_REMOVE_HIDDEN_CALENDAR_ITEMS_AFTER_WEEKS, DEFAULT_CALENDAR_ITEM_EXPIRATION);
Integer purgeItemsWithoutLinks = dashboardConfig.getConfigValue(DashboardConfig.PROP_REMOVE_CALENDAR_ITEMS_WITH_NO_LINKS, 0);

expireCalendarLinks(new Date(System.currentTimeMillis() - weeksToExpireItems.intValue() * ONE_WEEK_IN_MILLIS), false, false);
expireCalendarLinks(new Date(System.currentTimeMillis() - weeksToExpireStarredItems.intValue() * ONE_WEEK_IN_MILLIS), false, false);
expireCalendarLinks(new Date(System.currentTimeMillis() - weeksToExpireHiddenItems.intValue() * ONE_WEEK_IN_MILLIS), false, true);
purgeCalendarItems();
if(weeksToExpireItems.intValue() > 0) {
expireCalendarLinks(new Date(System.currentTimeMillis() - weeksToExpireItems.intValue() * ONE_WEEK_IN_MILLIS), false, false);
}
if(weeksToExpireStarredItems.intValue() > 0) {
expireCalendarLinks(new Date(System.currentTimeMillis() - weeksToExpireStarredItems.intValue() * ONE_WEEK_IN_MILLIS), false, false);
}
if(weeksToExpireHiddenItems.intValue() > 0) {
expireCalendarLinks(new Date(System.currentTimeMillis() - weeksToExpireHiddenItems.intValue() * ONE_WEEK_IN_MILLIS), false, true);
}
if(purgeItemsWithoutLinks.intValue() > 0) {
purgeCalendarItems();
}
}

private void purgeCalendarItems() {
Expand Down
2 changes: 2 additions & 0 deletions dashboard/impl/src/resources/hsqldb.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ insert into dash_config (id, property_name, property_value) values (NULL, 'PROP_
insert into dash_config (id, property_name, property_value) values (NULL, 'PROP_REMOVE_ITEMS_AFTER_WEEKS', 52); \
insert into dash_config (id, property_name, property_value) values (NULL, 'PROP_REMOVE_STARRED_ITEMS_AFTER_WEEKS', 26); \
insert into dash_config (id, property_name, property_value) values (NULL, 'PROP_REMOVE_HIDDEN_ITEMS_AFTER_WEEKS', 4); \
insert into dash_config (id, property_name, property_value) values (NULL, 'PROP_REMOVE_NEWS_ITEMS_WITH_NO_LINKS', 1); \
insert into dash_config (id, property_name, property_value) values (NULL, 'PROP_REMOVE_CALENDAR_ITEMS_WITH_NO_LINKS', 1); \
insert into dash_config (id, property_name, property_value) values (NULL, 'PROP_DAYS_BETWEEN_HORIZ0N_UPDATES', 1); \
insert into dash_config (id, property_name, property_value) values (NULL, 'PROP_WEEKS_TO_HORIZON', 4); \
insert into dash_config (id, property_name, property_value) values (NULL, 'PROP_MOTD_MODE', 1); \
Expand Down
2 changes: 2 additions & 0 deletions dashboard/impl/src/resources/mysql.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ insert into dash_config (property_name, property_value) values ('PROP_REMOVE_HID
insert into dash_config (property_name, property_value) values ('PROP_REMOVE_CALENDAR_ITEMS_AFTER_WEEKS', 2); \
insert into dash_config (property_name, property_value) values ('PROP_REMOVE_STARRED_CALENDAR_ITEMS_AFTER_WEEKS', 26); \
insert into dash_config (property_name, property_value) values ('PROP_REMOVE_HIDDEN_CALENDAR_ITEMS_AFTER_WEEKS', 1); \
insert into dash_config (property_name, property_value) values ('PROP_REMOVE_NEWS_ITEMS_WITH_NO_LINKS', 1); \
insert into dash_config (property_name, property_value) values ('PROP_REMOVE_CALENDAR_ITEMS_WITH_NO_LINKS', 1); \
insert into dash_config (property_name, property_value) values ('PROP_DAYS_BETWEEN_HORIZ0N_UPDATES', 1); \
insert into dash_config (property_name, property_value) values ('PROP_WEEKS_TO_HORIZON', 4); \
insert into dash_config (property_name, property_value) values ('PROP_MOTD_MODE', 1); \
Expand Down
2 changes: 2 additions & 0 deletions dashboard/impl/src/resources/oracle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ insert into dash_config (id, property_name, property_value) values (dash_config_
insert into dash_config (id, property_name, property_value) values (dash_config_seq.nextval, 'PROP_REMOVE_CALENDAR_ITEMS_AFTER_WEEKS', 2); \
insert into dash_config (id, property_name, property_value) values (dash_config_seq.nextval, 'PROP_REMOVE_STARRED_CALENDAR_ITEMS_AFTER_WEEKS', 26); \
insert into dash_config (id, property_name, property_value) values (dash_config_seq.nextval, 'PROP_REMOVE_HIDDEN_CALENDAR_ITEMS_AFTER_WEEKS', 1); \
insert into dash_config (id, property_name, property_value) values (dash_config_seq.nextval, 'PROP_REMOVE_NEWS_ITEMS_WITH_NO_LINKS', 1); \
insert into dash_config (id, property_name, property_value) values (dash_config_seq.nextval, 'PROP_REMOVE_CALENDAR_ITEMS_WITH_NO_LINKS', 1); \
insert into dash_config (id, property_name, property_value) values (dash_config_seq.nextval, 'PROP_DAYS_BETWEEN_HORIZ0N_UPDATES', 1); \
insert into dash_config (id, property_name, property_value) values (dash_config_seq.nextval, 'PROP_WEEKS_TO_HORIZON', 4); \
insert into dash_config (id, property_name, property_value) values (dash_config_seq.nextval, 'PROP_MOTD_MODE', 1); \
Expand Down

0 comments on commit 5ab3f2b

Please sign in to comment.