Skip to content

Commit

Permalink
Added logging for obtaining and releasing asset reservations (#2311)
Browse files Browse the repository at this point in the history
* Updates to account deletion content

* Added logging for obtaining and releasing asset reservations
  • Loading branch information
joshuastegmaier authored Mar 8, 2024
1 parent 7547de0 commit e832d26
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
14 changes: 14 additions & 0 deletions concordia/signals/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
@receiver(user_logged_in)
def clear_reservation_token(sender, user, request, **kwargs):
try:
token = request.session["reservation_token"]
del request.session["reservation_token"]
logger.info("Clearing reservation token %s for %s on login", token, user)
except KeyError:
pass
logger.info("Successful user login with username %s", user)
Expand Down Expand Up @@ -141,6 +143,12 @@ def send_asset_update(*, instance, **kwargs):

@receiver(reservation_obtained)
def send_asset_reservation_obtained(sender, **kwargs):
logger.info(
"Reservation obtained by %s for asset %s with token %s",
sender,
kwargs["asset_pk"],
kwargs["reservation_token"],
)
send_asset_reservation_message(
sender=sender,
message_type="asset_reservation_obtained",
Expand All @@ -151,6 +159,12 @@ def send_asset_reservation_obtained(sender, **kwargs):

@receiver(reservation_released)
def send_asset_reservation_released(sender, **kwargs):
logger.info(
"Reservation released by %s for asset %s with token %s",
sender,
kwargs["asset_pk"],
kwargs["reservation_token"],
)
send_asset_reservation_message(
sender=sender,
message_type="asset_reservation_released",
Expand Down
22 changes: 20 additions & 2 deletions concordia/static/js/src/asset-reservation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global jQuery displayMessage displayHtmlMessage buildErrorMessage */
/* global jQuery displayMessage displayHtmlMessage buildErrorMessage Sentry */
/* exported attemptToReserveAsset */

function attemptToReserveAsset(reservationURL, findANewPageURL, actionType) {
Expand All @@ -18,7 +18,7 @@ function attemptToReserveAsset(reservationURL, findANewPageURL, actionType) {
// If the asset was successfully reserved, continue reserving it
window.setTimeout(
attemptToReserveAsset,
60000,
60_000,
reservationURL,
findANewPageURL,
actionType,
Expand All @@ -40,19 +40,37 @@ function attemptToReserveAsset(reservationURL, findANewPageURL, actionType) {
'">Find a new page to review</a>',
'transcription-reservation',
);
Sentry.captureException(errorThrown, function (scope) {
scope.setTransactionName(
'409 error when attempting to reserve asset at ' +
reservationURL,
);
});
}
} else if (jqXHR.status == 408) {
$transcriptionEditor
.data('hasReservation', false)
.trigger('update-ui-state');
jQuery('#asset-reservation-failure-modal').modal();
Sentry.captureException(errorThrown, function (scope) {
scope.setTransactionName(
'408 error when attempting to reserve asset at ' +
reservationURL,
);
});
} else {
displayMessage(
'error',
'Unable to reserve this page: ' +
buildErrorMessage(jqXHR, textStatus, errorThrown),
'transcription-reservation',
);
Sentry.captureException(errorThrown, function (scope) {
scope.setTransactionName(
'Error when attempting to reserve asset at ' +
reservationURL,
);
});
}
});

Expand Down

0 comments on commit e832d26

Please sign in to comment.