<!--[if (gte mso 9)|(IE)]><style type="text/css">.main-style-e9b726cb757c8ea2244e { font-family: sans-serif; font-size: 11pt; /* inherit */ }</style><![endif]-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div style="/* inherit */" class="main-style-e9b726cb757c8ea2244e">
<div>Hi Everyone,</div>
<div><br>
</div>
<div>First question from me I appreciate this is policy engine thing as opposed to more fundamental Spectrum Scale so hope its ok!</div>
<div><br>
</div>
<div>I'm trying to find a 'neat' way within a couple of policy rules to measure different time intervals (in days) but solely interested in WEEK DAYS only (ie delete files older than X week days only).</div>
<div><br>
</div>
<div>An example is one of the rules a team would like implemented is delete all files older than 10 business days (ie week days only. We are ignoring public holidays as if they don't exist). Followed by a separate rule for a different folder of deleting all
 files older than 4 business days.</div>
<div><br>
</div>
<div>The only way I've been able to facilitate this so far for the 4 business days is to separate out Fridays as a separate rule (because Friday - 4 days are all week days), then a separate rule for Monday through Thursday (because timestamp - 4 days has to
 factor in weekends, so has to actually set the INTERVAL to 6 days). Likewise for the 10 days rule I have to have a method to separate out Monday - Wednesday, and Thursday and Friday.</div>
<div><br>
</div>
<div>I feel my 'solution', which does work, is extremely messy and not ideal should they want to add more rules as it just makes the policy file very long full of random definitions for all the different scenarios.</div>
<div><br>
</div>
<div>So whilst the 'rules' are simple thanks to definitions, its the definitions themselves that are stacking up... depending on the interval required I have to create a unique set of is_weekday definitions and unique is_older_than_xdays definitions.</div>
<div><br>
</div>
<div>here is a snippet of the policy:</div>
<div><br>
</div>
<blockquote style="margin: 0 0 0 7px; border-left: 3px solid #bbbdbf; padding-left: 10px;">
<div>define(</div>
<div style="margin-left: 2em;">is_older_than_4days,</div>
<div style="margin-left: 2em;">(</div>
<div style="margin-left: 3em;">(CURRENT_TIMESTAMP - CREATION_TIME) >= INTERVAL '4' DAYS</div>
<div style="margin-left: 2em;">)</div>
<div>)</div>
<div><br>
</div>
<div>define(</div>
<div style="margin-left: 1em;">is_older_than_6days,</div>
<div style="margin-left: 1em;">(</div>
<div style="margin-left: 2em;">(CURRENT_TIMESTAMP - CREATION_TIME) >= INTERVAL '6' DAYS</div>
<div style="margin-left: 1em;">)</div>
<div>)</div>
<div><br>
</div>
<div>define(</div>
<div style="margin-left: 1em;">is_weekday_ex_fri,</div>
<div style="margin-left: 1em;">(</div>
<div style="margin-left: 2em;">DAYOFWEEK(CURRENT_DATE) IN (2,3,4,5)</div>
<div style="margin-left: 1em;">)</div>
<div>)</div>
<div><br>
</div>
<div>define(</div>
<div style="margin-left: 1em;">is_weekday_ex_fri,</div>
<div style="margin-left: 1em;">(</div>
<div style="margin-left: 2em;">DAYOFWEEK(CURRENT_DATE) = 6</div>
<div style="margin-left: 1em;">)</div>
<div>)</div>
<div><br>
</div>
<div>RULE 'rule name' WHEN is_weekday_ex_fri DELETE</div>
<div>WHERE</div>
<div style="margin-left: 1em;">include_list /* an include list just not added above */</div>
<div style="margin-left: 1em;">AND is_older_than_6days</div>
<div><br>
</div>
<div>RULE 'rule name' WHEN is_fri DELETE</div>
<div>WHERE</div>
<div style="margin-left: 1em;">include_list /* an include list just not added above */</div>
<div style="margin-left: 1em;">AND is_older_than_4days </div>
</blockquote>
<div style="margin-left: 1em;"><br>
</div>
<div>Are there any 'neat' other ways that are a tad more 'concise' for calculating INTERVAL X weekdays only which is easily and concisely extendable for any permutation of intervals required. </div>
<div><br>
</div>
<div>I'm not sure how much SQL you can shoehorn into a policy before mmapplypolicy / policy engine isn't happy.</div>
<div><br>
</div>
<div>Thanks in advance,</div>
<div><br>
</div>
<div>Owen.</div>
</div>
<img alt="Sent from Front" aria-hidden="true" style="width: 1px; height: 1px" src="https://app.frontapp.com/api/1/noauth/companies/lansat/seen/msg_9avo11g/0/bb589f61.gif">
<div style="mso-line-height-rule:exactly;-webkit-text-size-adjust:100%;"><table cellpadding="0" cellspacing="0" border="0" style="width:100%;"><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;line-height:normal;"><tr style="font-size:0;"><td style="padding:0;"> </td><td style="padding:10px 0 0;"> </td></tr><tr style="font-size:0;"><td align="left" style="padding:0 4px 0 0;border-top:none;border-right:solid 1px #FFCC00;border-bottom:none;border-left:none;vertical-align:middle;"><img src="http://www.motionpicturesolutions.com/wp-content/uploads/2018/06/MPSEmail.jpg" height="91" border="0" alt="" style="height:91px;min-height:91px;max-height:91px;font-size:0;" /></td><td align="left" style="padding:10px 0 10px 10px;vertical-align:middle;"><table cellpadding="0" cellspacing="0" border="0" style="width:100%;font-size:0;font-style:normal;font-weight:700;white-space:nowrap;"><tr style="font-size:12px;color:#FFCC00;"><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;">Owen Morgan<span style="font-family:remialcxesans;font-size:1px;color:#FFFFFF;line-height:1px;">​</span></td></tr><tr style="font-size:10.67px;color:#232323;"><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;">Data Wrangler</td></tr><tr style="font-size:10.67px;color:#232323;"><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif;">Motion Picture Solutions Ltd</td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;"><tr style="font-size:0;"><td align="left" style="padding:10px 0 0;vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#232323;font-style:normal;font-weight:400;white-space:nowrap;"><tr style="font-size:10.67px;"><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif;"><span style="font-weight:700;">T:</span> <a href="tel:" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#232323;"><strong style="font-weight:400;"></strong></a></td></tr></table></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#232323;font-style:normal;font-weight:400;white-space:nowrap;"><tr style="font-size:10.67px;"><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif;"><span style="font-weight:700;">E:</span> <a href="mailto:owen.morgan@motionpicturesolutions.com" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#232323;"><strong style="font-weight:400;">owen.morgan@motionpicturesolutions.com</strong></a></td><td align="center" style="vertical-align:middle;font-size:12px;color:#FED400;font-family:Calibri,Arial,sans-serif;"> | </td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif;font-weight:700;">W: <span style="font-weight:400;"><a href="https://www.motionpicturesolutions.com/" target="_blank" id="LPlnk689713" style="text-decoration:none;color:#232323;"><strong style="font-weight:400;">motionpicturesolutions.com</strong></a></span></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0;color:#232323;font-style:normal;font-weight:400;white-space:nowrap;"><tr style="font-size:10.67px;"><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif;font-weight:700;">A: </td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif;">Mission Hall, 9‑11 North End Road</td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif;">, </td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif;">London</td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif;">, </td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif;">W14 8ST<br /></td></tr></table></td></tr></table></td></tr></table></td></tr><tr style="font-size:0;"><td align="left" style="vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="width:100%;font-size:0;"><tr style="font-size:0;"><td align="left" style="padding:10px 0 0;vertical-align:top;"><table cellpadding="0" cellspacing="0" border="0" style="white-space:normal;color:#C0C0C0;font-size:14.67px;font-family:Calibri,Arial,sans-serif;font-weight:400;font-style:normal;text-align:justify;width:100%;"><tr style="font-size:10.67px;"><td style="font-family:Calibri,Arial,sans-serif;">Motion Picture Solutions Ltd is a company registered in England and Wales under number 5388229, VAT number 201330482</td></tr></table></td></tr></table></td></tr></table></div></body>
</html>