Skip to content

Commit

Permalink
[cuebot] Add a new property max_show_stale_days to control show expir…
Browse files Browse the repository at this point in the history
…ation rule. (#1208)
  • Loading branch information
DiegoTavares committed Sep 29, 2022
1 parent d458bc2 commit 962b227
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,32 +237,22 @@ public void updateShowCommentEmail(ShowInterface s, String[] email) {

@Override
public void updateShowsStatus() {
Stream<String> protectedShowsRaw = Arrays.stream(env.getProperty("protected_shows", String.class).split(","));
Stream<String> protectedShowsRaw = Arrays
.stream(env.getProperty("protected_shows", String.class, "").split(","));
String protectedShows = protectedShowsRaw.map(show -> "'" + show + "'")
.collect(Collectors.joining(","));
getJdbcTemplate().update("UPDATE " +
"show " +
"SET " +
"b_active=false " +
"WHERE " +
"pk_show NOT IN (" +
"SELECT " +
"pk_show " +
"FROM (" +
"SELECT " +
"pk_show, count(pk_job) " +
"FROM " +
"job_history " +
"WHERE " +
"(DATE_PART('days', NOW()) - DATE_PART('days', dt_last_modified)) < 30 " +
"GROUP BY " +
"pk_show " +
"HAVING COUNT(pk_job)>0 " +
") pk_show" +
") " +
"AND " +
"str_name NOT IN (?)",
protectedShows);
int maxShowStaleDays = env.getProperty("max_show_stale_days", Integer.class, -1);

if (maxShowStaleDays > 0) {
getJdbcTemplate().update("UPDATE show SET b_active=false " +
"WHERE pk_show NOT IN (SELECT pk_show " +
" FROM (SELECT pk_show, count(pk_job) FROM job_history " +
" WHERE " +
" (DATE_PART('days', NOW()) - DATE_PART('days', dt_last_modified)) < ? " +
"GROUP BY pk_show HAVING COUNT(pk_job) > 0) pk_show) " +
" AND str_name NOT IN (?)",
maxShowStaleDays, protectedShows);
}
}

@Override
Expand Down
9 changes: 7 additions & 2 deletions cuebot/src/main/resources/opencue.properties
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,13 @@ maintenance.auto_delete_down_hosts=false
# Set hostname/IP of the smtp host. Will be used for mailing
smtp_host=smtp

# These shows won't be deactivated by the scheduled tasks
protected_shows=pipe,swtest,edu
# Flags related to a job that runs periodically to deactivate shows that haven't been
# receiving jobs.
# A comma separated list of shows that won't be deactivated by the scheduled tasks
protected_shows=testing
# Number of days a show needs to be stale before it gets deactivated.
# -1 means shows should not get deactivated at all.
max_show_stale_days=-1

# These flags determine whether or not layers/frames will be readonly when job is finished.
# If flags are set as true, layers/frames cannot be retried, eaten, edited dependency on, etc.
Expand Down

0 comments on commit 962b227

Please sign in to comment.