Skip to content
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

Refactor LoanInfo and HoldInfo to be dataclasses (PP-1728) #2113

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jonathangreen
Copy link
Member

@jonathangreen jonathangreen commented Oct 15, 2024

Description

Refactor LoanInfo and HoldInfo to be simple dataclasses, and move the logic for creating and updating loans and holds from a LoanInfo or HoldInfo into a method called create_or_update.

In the process, I removed the Hold.external_identifier column, which appears to be unused.

Motivation and Context

Needed to modify how LoanInfo and HoldInfo are used as part of PP-1728, this refactor makes that work easier, but I thought it would be easier to understand as a separate PR.

How Has This Been Tested?

  • Running tests

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jonathangreen jonathangreen requested a review from a team October 15, 2024 19:45
@jonathangreen jonathangreen changed the title Refactor LoanInfo and HoldInfo to be dataclasses Refactor LoanInfo and HoldInfo to be dataclasses (PP-1728) Oct 15, 2024
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 90.17857% with 11 lines in your changes missing coverage. Please review.

Project coverage is 90.71%. Comparing base (5155b4d) to head (4e69c0c).

Files with missing lines Patch % Lines
src/palace/manager/api/axis.py 68.75% 4 Missing and 1 partial ⚠️
src/palace/manager/api/circulation.py 95.94% 2 Missing and 1 partial ⚠️
src/palace/manager/api/enki.py 33.33% 1 Missing and 1 partial ⚠️
src/palace/manager/api/bibliotheca.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2113      +/-   ##
==========================================
+ Coverage   90.69%   90.71%   +0.02%     
==========================================
  Files         351      351              
  Lines       40878    40878              
  Branches     8858     8853       -5     
==========================================
+ Hits        37073    37084      +11     
+ Misses       2493     2487       -6     
+ Partials     1312     1307       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1423,14 +1410,6 @@ def _raise_exception_on_error(


class XMLResponseParser(ResponseParser, Axis360Parser[T], ABC):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here make the XMLResponseParser subclasses return the parsed data directly, rather then a LoanInfo or HoldInfo object. Previously they returned a partial object, and the caller had to fill in the missing details, now the caller creates the whole LoanInfo or HoldInfo object.

"""Either turn the given document into a LoanInfo
object, or raise an appropriate exception.
"""
self.raise_exception_on_error(e, namespaces)

# If we get to this point it's because the checkout succeeded.
expiration_date = self._xpath1(e, "//axis:expirationDate", namespaces)
fulfillment_url = self._xpath1(e, "//axis:url", namespaces)
if fulfillment_url is not None:
fulfillment_url = fulfillment_url.text
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was parsed, but never used.

@jonathangreen
Copy link
Member Author

This one has some missing coverage, but all the lines that are not covered, we not previously covered, so I think it should be fine to merge as is.

@jonathangreen jonathangreen added the DB migration This PR contains a DB migration label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DB migration This PR contains a DB migration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant