Skip to content

Commit

Permalink
Don't add "I-care" classification to TNS sources (#89)
Browse files Browse the repository at this point in the history
* don't add GRANDMA classifications to TNS sources
  • Loading branch information
Theodlz authored Apr 12, 2024
1 parent 8b2be08 commit 787bf34
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions extensions/skyportal/skyportal/models/source_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ def source_after_insert(mapper, connection, target):

@event.listens_for(inspect(target).session, "after_flush", once=True)
def receive_after_flush(session, context):

# first check if the obj.id is in the format 20YY[a-zA-Z] (e.g. 2021a, or 2024aaav)
# it should be in that format and nothing else, meaning nothing before or after the 20YY[a-zA-Z] format
# in which case we don't want to add the classification
tns_name_regex = r'20\d{2}[a-zA-Z]+'
if re.fullmatch(tns_name_regex, target.id):
log(f"TNS object {target.id}, not adding classification I-care")
return
# find the taxonomy
try:
user = session.scalars(sa.select(User).where(User.id == 1)).first()
Expand Down

0 comments on commit 787bf34

Please sign in to comment.