mirror of
https://github.com/bitwarden/server.git
synced 2025-07-13 05:38:25 -05:00
premium renewal reminders job for braintree
This commit is contained in:
@ -226,5 +226,7 @@
|
||||
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadCountByOrganizationIdEmail.sql" />
|
||||
<Build Include="dbo\Stored Procedures\CipherDetails_ReadWithoutOrganizationsByUserId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\CollectionCipher_UpdateCollectionsForCiphers.sql" />
|
||||
<Build Include="dbo\Stored Procedures\User_ReadByPremiumRenewal.sql" />
|
||||
<Build Include="dbo\Stored Procedures\User_UpdateRenewalReminderDate.sql" />
|
||||
</ItemGroup>
|
||||
</Project>
|
23
src/Sql/dbo/Stored Procedures/User_ReadByPremiumRenewal.sql
Normal file
23
src/Sql/dbo/Stored Procedures/User_ReadByPremiumRenewal.sql
Normal file
@ -0,0 +1,23 @@
|
||||
CREATE PROCEDURE [dbo].[User_ReadByPremiumRenewal]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
DECLARE @WindowRef DATETIME2(7) = GETUTCDATE()
|
||||
DECLARE @WindowStart DATETIME2(7) = DATEADD (day, -15, @WindowRef)
|
||||
DECLARE @WindowEnd DATETIME2(7) = DATEADD (day, 15, @WindowRef)
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[UserView]
|
||||
WHERE
|
||||
[Premium] = 1
|
||||
AND [PremiumExpirationDate] >= @WindowRef
|
||||
AND [PremiumExpirationDate] < @WindowEnd
|
||||
AND (
|
||||
[RenewalReminderDate] IS NULL
|
||||
OR [RenewalReminderDate] < @WindowStart
|
||||
)
|
||||
AND [Gateway] = 1 -- Braintree
|
||||
END
|
@ -0,0 +1,14 @@
|
||||
CREATE PROCEDURE [dbo].[User_UpdateRenewalReminderDate]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@RenewalReminderDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
UPDATE
|
||||
[dbo].[User]
|
||||
SET
|
||||
[RenewalReminderDate] = @RenewalReminderDate
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
Reference in New Issue
Block a user