Skip to content

Commit

Permalink
Merge pull request #272 from NYPL/HOTFIX_DeleteWorkFromQAFrontend
Browse files Browse the repository at this point in the history
HOTFIX_DeleteWorkFromQAFrontend
  • Loading branch information
mitri-slory authored Aug 25, 2023
2 parents 42224dc + fa116aa commit c21423f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## unreleased version -- v0.12.2
### Added
- Script to count and return ids of PD Univ of Cali Books from Hathitrust
- Script to delete problem work records from PSQL and ESC
### Fixed
- Publisher location and webpub manifest links for ISAC records

Expand Down
32 changes: 32 additions & 0 deletions scripts/deleteProblemWorks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os

from model import Work
from managers import DBManager, ElasticsearchManager
from elasticsearch_dsl import Search

def main():

dbManager = DBManager(
user= os.environ.get('POSTGRES_USER', None),
pswd= os.environ.get('POSTGRES_PSWD', None),
host= os.environ.get('POSTGRES_HOST', None),
port= os.environ.get('POSTGRES_PORT', None),
db= os.environ.get('POSTGRES_NAME', None)
)

esManager = ElasticsearchManager()
esManager.createElasticConnection()

dbManager.generateEngine()

dbManager.createSession()

uuid = '0288f50c-f2db-47fc-9ff9-b8b95b4cc712'

dbManager.session.query(Work).filter(Work.uuid == uuid).delete()

resp = Search(index=os.environ['ELASTICSEARCH_INDEX']).query('match', uuid=uuid)
resp.delete()

dbManager.session.commit()
dbManager.session.close()

0 comments on commit c21423f

Please sign in to comment.