Skip to content

Commit

Permalink
SFR_1826_NYPLLoginFlag
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Nov 28, 2023
1 parent d14eab0 commit 746c148
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## unreleased version -- v0.12.4
## Added
- New script to add nypl_login flag to Links objects
## Fixed

## 2023-09-05 version -- v0.12.3
## Removed
- The "*" character is escaped from queries passed to ElasticSearch, limiting wildcard searches
Expand Down
3 changes: 2 additions & 1 deletion scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
from .interstitialPagesSFR1410 import main as interstitialPages
from .ingestS3Metadata import main as ingestS3
from .updatePubLocationAndLinks import main as updateLocationAndLinks
from .countCABooks import main as countCABooks
from .countCABooks import main as countCA
from .nyplLoginFlags import main as nyplFlags
35 changes: 35 additions & 0 deletions scripts/nyplLoginFlags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os

from model import Link
from managers import DBManager
from sqlalchemy import or_
import json

def main():

'''Updating NYPL Link flags with a new nypl_login flag'''

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)
)

dbManager.generateEngine()

dbManager.createSession()

for link in dbManager.session.query(Link) \
.filter(or_(Link.media_type == 'application/html+edd', Link.media_type == 'application/x.html+edd')).all():
if link.flags['edd'] == True:
#The link.flags doesn't update if the dict method isn't called on it
newLinkFlag = dict(link.flags)
newLinkFlag['nypl_login'] = True
link.flags = newLinkFlag

dbManager.commitChanges()

if __name__ == '__main__':
main()

0 comments on commit 746c148

Please sign in to comment.