问题描述
- 仅当作业的状态为“进行中”且大于SLA_TMLINE时,我才需要在几分钟内计算和填充字段“ DURATION_CROSSED_AFTER_SLA”方面需要帮助。如果SLA_TMLINE为'NA',则字段也将为'NA'。 SLA_TMLINE值仅在time(EST)中给出,而计算时将自动采用当前日期,例如:对于JOB_ID 1373,SLA_TMLINE给出为-06:00 AM,表示'8/22/2020 06:00: 00'。
- 如果作业的状态为“进行中”,并且当前日期的当前时间戳(0)> SLA_TMLINE +“ 1”小时,则我们需要将作业的状态(B.STATUS)显示为“长时间运行” ”,而不是“进行中”。
基本上,我们将获得以下工作状态:
class Weather {
async getCoordinates() {
//code
}
async getWeatherForecast(locationCoordinates) {
//code
}
fahrenheitToCelsius(temp) {
//code
}
renderForecastInfo(currently,daily) {
//code
}
init() {
getCoordinates().then(coords => {
return getWeatherForecast(coords);
}).then((forecast) => {
const { currently,daily } = forecast;
renderForecastInfo(currently,daily);
});
}
}
从以上5种工作状态中,表中没有'LONG RUNNING'状态,但是我们将根据第n点得出它。以上2。
WAITING
IN PROGRESS
LONG RUNNING
COMPLETE
FAILED
解决方法
棘手的部分是存储为VarChar的时间和个位数小时。可以使用RegEx或LPAD添加缺少的前导零:
cast(lpad(nullif(SLA_TMLINE,'NA'),8,'0') as time(0) format 'hh:miBT')
将其投射到时间戳记时,默认值为今天:
cast(cast(lpad(nullif(SLA_TMLINE,'0') as time(0) format 'hh:miBT') as timestamp(0)) as SLA_TS
然后是
case
when status = 'IN PROGRESS'
and SLA_TS < current_timestamp - interval '1' hour
then 'LONG RUNNING'
else status
end
case
when status = 'IN PROGRESS'
and SLA_TS < current_timestamp
then (current_timestamp(0) - SLA_TS minute(4))
end