-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[PM-27886] - Archive Revamp: Replace ArchiveDate from Cipher Entity and SQL Files #6589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: PM-27884
Are you sure you want to change the base?
Changes from all commits
5b300de
9ed0c16
5c65756
d07bf31
f75cdaf
a8d8fcf
e1a238d
933e199
53ea531
dfb5312
806ccb1
5e8f1f1
da0131c
2565199
3ae4abb
9813cb1
6a09715
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐จ I think it would be preferable to put the additional join in the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shane-melton Totally agree. I had done that originally but then had a bunch of failing sql and tests that couldn't seem to handle the nested join. I'll see if I can get them to work again.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shane-melton this is now resolved in da0131c |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,31 @@ | ||
| CREATE PROCEDURE [dbo].[Cipher_Archive] | ||
| @Ids AS [dbo].[GuidIdArray] READONLY, | ||
| @UserId AS UNIQUEIDENTIFIER | ||
| @Ids dbo.GuidIdArray READONLY, | ||
| @UserId UNIQUEIDENTIFIER | ||
| AS | ||
| BEGIN | ||
| SET NOCOUNT ON | ||
|
|
||
| CREATE TABLE #Temp | ||
| DECLARE @UtcNow DATETIME2(7) = SYSUTCDATETIME(); | ||
|
|
||
| WITH CipherIdsToArchive AS | ||
| ( | ||
| [Id] UNIQUEIDENTIFIER NOT NULL, | ||
| [UserId] UNIQUEIDENTIFIER NULL | ||
| SELECT DISTINCT C.Id | ||
| FROM [dbo].[Cipher] C | ||
| INNER JOIN @Ids I ON C.Id = I.[Id] | ||
| WHERE (C.[UserId] = @UserId) | ||
jaasen-livefront marked this conversation as resolved.
Show resolved
Hide resolved
jaasen-livefront marked this conversation as resolved.
Show resolved
Hide resolved
jaasen-livefront marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| INSERT INTO #Temp | ||
| SELECT | ||
| [Id], | ||
| [UserId] | ||
| FROM | ||
| [dbo].[UserCipherDetails](@UserId) | ||
| WHERE | ||
| [Edit] = 1 | ||
| AND [ArchivedDate] IS NULL | ||
| AND [Id] IN (SELECT * FROM @Ids) | ||
|
|
||
| DECLARE @UtcNow DATETIME2(7) = SYSUTCDATETIME(); | ||
| UPDATE | ||
| [dbo].[Cipher] | ||
| SET | ||
| [ArchivedDate] = @UtcNow, | ||
| [RevisionDate] = @UtcNow | ||
| WHERE | ||
| [Id] IN (SELECT [Id] FROM #Temp) | ||
| INSERT INTO [dbo].[CipherArchive] (CipherId, UserId, ArchivedDate) | ||
| SELECT Cta.Id, @UserId, @UtcNow | ||
| FROM CipherIdsToArchive Cta | ||
| WHERE NOT EXISTS | ||
| ( | ||
jaasen-livefront marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| SELECT 1 | ||
| FROM [dbo].[CipherArchive] Ca | ||
| WHERE Ca.CipherId = Cta.Id | ||
| AND Ca.UserId = @UserId | ||
| ); | ||
|
|
||
| EXEC [dbo].[User_BumpAccountRevisionDate] @UserId | ||
|
|
||
| DROP TABLE #Temp | ||
|
|
||
| SELECT @UtcNow | ||
| END | ||
Uh oh!
There was an error while loading. Please reload this page.