Skip to content

Commit 8d0a520

Browse files
committed
+ Added script to report all idle connection requests.
1 parent c83edce commit 8d0a520

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
-- =====================================================================================================
2+
-- Author: Jon Edmiston
3+
-- Create Date: 2/23/2021
4+
-- Description: This script will display idle requests for a given Connection Type.
5+
-- Note that we are only filtering on requests with a State of idle (ignoring future follow-ups)/
6+
-- In the next release (v12.2) a job will be changing the State of future follow-ups to active
7+
-- when their future follow-up date is past.
8+
--
9+
-- This script is meant to be a starting point for other features.
10+
--
11+
-- Change History:
12+
--
13+
-- =====================================================================================================
14+
15+
DECLARE @ConnectionTypeId int = 1 -- The Connection Type we are wanting to filter on.
16+
17+
-------------------------------------------------------------------------------------------------------
18+
19+
SELECT
20+
*
21+
FROM
22+
-- a sub-select to get requests and their days since last activity
23+
(SELECT
24+
cr.[Id]
25+
, ISNULL (
26+
DATEDIFF(
27+
day
28+
, (SELECT MAX(cra.[CreatedDateTime]) FROM [ConnectionRequestActivity] cra WHERE cra.[ConnectionRequestId] = cr.[Id] )
29+
, GETDATE() )
30+
, DATEDIFF( day, cr.[CreatedDateTime], GETDATE() )
31+
) AS [DaysSinceLastActivity]
32+
FROM
33+
[ConnectionRequest] cr
34+
INNER JOIN [ConnectionOpportunity] co ON co.[Id] = cr.[ConnectionOpportunityId]
35+
INNER JOIN [ConnectionType] ct ON ct.[Id] = co.[ConnectionTypeId]
36+
WHERE
37+
ct.[Id] = @ConnectionTypeId
38+
AND [ConnectionState] = 0) AS [Requests]
39+
WHERE
40+
[DaysSinceLastActivity] > 14

0 commit comments

Comments
 (0)