Commit e3e65c2c authored by dasharatha.vamshi's avatar dasharatha.vamshi

Update v_batch_running.txt

parent 53f12692
......@@ -3,12 +3,40 @@ create or replace view v_batch_running as
subquery.process_stage_id,
subquery.master_product_id,
subquery.batch_start,
concat((subquery.hours)::text, ' hrs', ' : ', lpad((subquery.minutes)::text, 2, '0'::text), ' mins') AS duration_formatted
concat(
CASE
WHEN (subquery.years > (0)::numeric) THEN ((subquery.years)::text || 'y '::text)
ELSE ''::text
END,
CASE
WHEN ((subquery.months > (0)::numeric) AND (subquery.months < (12)::numeric)) THEN ((subquery.months)::text || 'mon '::text)
ELSE ''::text
END,
CASE
WHEN ((subquery.weeks > (0)::numeric) AND (subquery.weeks < (4)::numeric)) THEN ((subquery.weeks)::text || 'w '::text)
ELSE ''::text
END,
CASE
WHEN ((subquery.days > (0)::numeric) AND (subquery.days < (7)::numeric)) THEN ((subquery.days)::text || 'd '::text)
ELSE ''::text
END,
CASE
WHEN ((subquery.hours > (0)::numeric) AND (subquery.hours < (24)::numeric)) THEN ((subquery.hours)::text || 'h '::text)
ELSE ''::text
END,
CASE
WHEN ((subquery.minutes > (0)::numeric) AND (subquery.minutes < (60)::numeric)) THEN ((subquery.minutes)::text || 'm'::text)
ELSE ''::text
END) AS duration_formatted
FROM ( SELECT batch_details.batch_no,
batch_details.process_stage_id,
batch_details.master_product_id,
batch_details.batch_start,
((date_part('day'::text, (now() - batch_details.batch_start)) * (24)::double precision) + date_part('hour'::text, (now() - batch_details.batch_start))) AS hours,
date_part('minute'::text, (now() - batch_details.batch_start)) AS minutes
floor((EXTRACT(epoch FROM (now() - batch_details.batch_start)) / (((((60 * 60) * 24) * 7) * 52))::numeric)) AS years,
(floor((EXTRACT(epoch FROM (now() - batch_details.batch_start)) / ((((60 * 60) * 24) * 30))::numeric)) % (12)::numeric) AS months,
(floor((EXTRACT(epoch FROM (now() - batch_details.batch_start)) / ((((60 * 60) * 24) * 7))::numeric)) % (52)::numeric) AS weeks,
(floor((EXTRACT(epoch FROM (now() - batch_details.batch_start)) / (((60 * 60) * 24))::numeric)) % (7)::numeric) AS days,
(floor((EXTRACT(epoch FROM (now() - batch_details.batch_start)) / ((60 * 60))::numeric)) % (24)::numeric) AS hours,
(floor((EXTRACT(epoch FROM (now() - batch_details.batch_start)) / (60)::numeric)) % (60)::numeric) AS minutes
FROM batch_details
WHERE ((batch_details.batch_start IS NOT NULL) AND (batch_details.batch_end IS NULL))) subquery;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment