-
Notifications
You must be signed in to change notification settings - Fork 1
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
DOP-5018: Add functionality to delete stale properties and documents from Search database #6
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
30cfe94
DOP-5018 add logic for deleting stale properties, documents
anabellabuckvar 06c8ada
DOP-5018 tests for deleteStale WIP
anabellabuckvar 94d469b
DOP-5018 improvements made while writing tests
anabellabuckvar 75cf557
DOP-5018 more mock data, finished tests
anabellabuckvar 1948f4d
DOP-5018 add last test
anabellabuckvar c06f6bd
DOP-5018 merge in latest from DOP-5007
anabellabuckvar 200be08
DOP-5018 cleaning up
anabellabuckvar 4aec455
Merge branch 'DOP-5007', remote-tracking branch 'origin' into DOP-5018
anabellabuckvar efb7635
DOP-5018 merge DOP-5007 in
anabellabuckvar 51d42a9
DOP-5018 remove assertion for global property
anabellabuckvar 03306aa
DOP-5018 create EnvironmentConfig interface
anabellabuckvar 0b85fe8
Merge branch 'main' into DOP-5018
anabellabuckvar d76da87
Merge remote-tracking branch 'origin/DOP-5018' into DOP-5018
anabellabuckvar c998d2f
DOP-5018 cleaning
anabellabuckvar f40e3e5
DOP-5018 cleaning
anabellabuckvar 87dcb7c
DOP-5018 update tests to comply with changes
anabellabuckvar 3bb6645
DOP-5018 cleaning
anabellabuckvar 3bdcf5f
DOP-5018 cleaning
anabellabuckvar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
search-manifest/src/uploadToAtlas/deleteStaleProperties.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { db, teardown } from "./searchConnector"; | ||
import { DatabaseDocument } from "./types"; | ||
|
||
const ATLAS_SEARCH_URI = `mongodb+srv://${process.env.MONGO_ATLAS_USERNAME}:${process.env.MONGO_ATLAS_PASSWORD}@${process.env.MONGO_ATLAS_SEARCH_HOST}/?retryWrites=true&w=majority`; | ||
|
||
//TODO: change these teamwide env vars in Netlify UI when ready to move to prod | ||
const SEARCH_DB_NAME = `${process.env.MONGO_ATLAS_SEARCH_DB_NAME}`; | ||
|
||
export const deleteStaleProperties = async (searchProperty: string) => { | ||
const dbSession = await db({ uri: ATLAS_SEARCH_URI, dbName: SEARCH_DB_NAME }); | ||
const documentsColl = dbSession.collection<DatabaseDocument>("documents"); | ||
console.debug(`Removing old documents`); | ||
const query = { searchProperty: { $regex: searchProperty } }; | ||
const status = await documentsColl?.deleteMany(query); | ||
return status; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can put the teardown function call at the end of the integration callback function somewhere here. Basically, the end of the
addBuildEventHandler
callback, you can add the teardown thereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed async, postponing to solve in later ticket