Skip to content

Commit

Permalink
add moved rules to diff generation
Browse files Browse the repository at this point in the history
  • Loading branch information
lunakv committed Jun 12, 2023
1 parent e8de00a commit 695d919
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/database/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def apply_pending_cr_and_diff(db: Session, set_code: str, set_name: str) -> None
source_id=pendingDiff.source_id,
dest=newCr,
changes=pendingDiff.changes,
moves=pendingDiff.moves,
)
db.add(newCr)
db.add(newDiff)
Expand Down Expand Up @@ -181,10 +182,12 @@ def get_mtr_diff_metadata(db: Session):
return db.execute(stmt).fetchall()


def set_pending_cr_and_diff(db: Session, new_rules: dict, new_diff: list, file_name: str):
def set_pending_cr_and_diff(db: Session, new_rules: dict, new_diff: list, file_name: str, new_moves: list):
new_cr = PendingCr(creation_day=datetime.date.today(), data=new_rules, file_name=file_name)
curr_cr_id: Cr = db.execute(select(Cr.id).order_by(Cr.creation_day.desc())).scalars().first()
new_diff = PendingCrDiff(creation_day=datetime.date.today(), source_id=curr_cr_id, dest=new_cr, changes=new_diff)
new_diff = PendingCrDiff(
creation_day=datetime.date.today(), source_id=curr_cr_id, dest=new_cr, changes=new_diff, moves=new_moves
)
db.add(new_cr)
db.add(new_diff)

Expand Down
2 changes: 1 addition & 1 deletion app/parsing/cr/refresh_cr.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async def refresh_cr(link):
# TODO add to database instead?
KeywordCache().replace(result["keywords"])
GlossaryCache().replace(result["glossary"])
ops.set_pending_cr_and_diff(session, result["rules"], diff_result.diff, file_name)
ops.set_pending_cr_and_diff(session, result["rules"], diff_result.diff, file_name, diff_result.moved)


if __name__ == "__main__":
Expand Down

0 comments on commit 695d919

Please sign in to comment.