Advertisement
DataCCIW

Merge Request Notification Count

Sep 22nd, 2022
1,455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.83 KB | None | 0 0
  1. /* The query below mirrors entitySetQry found in PersonMergeRequestList.ascx.cs found on github
  2. within Rock/RockWeb/Blocks/Crm/
  3.  
  4. Join and Filter Notes:
  5. * If a merge request is deleted instead of processed the ExpireDate is set
  6. * There are other entity sets stored in the [EntitySetItem] table
  7.    so we need to filter down to those that have a merge request purpose
  8. */
  9.  
  10.  
  11. DECLARE @ENTITY_SET_PURPOSE_PERSON_MERGE_REQUEST uniqueidentifier  = '214EB26F-5493-4540-B2EF-F0887C8FBB9E';
  12. DECLARE @dateTimeNow datetime = GETDATE();
  13.  
  14. SELECT COUNT (DISTINCT E.Id) as mergeRequestCount
  15.   FROM [dbo].[EntitySetItem] EI
  16.   join EntitySet E on E.Id = EI.EntitySetId
  17.   join DefinedValue D on D.Id = E.EntitySetPurposeValueId and D.Guid = @ENTITY_SET_PURPOSE_PERSON_MERGE_REQUEST
  18.   WHERE E.ExpireDateTime is null or E.ExpireDateTime > @dateTimeNow;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement