From 240867de310bfb8d58f9b54e66631e87fa9b70ac Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 18 Apr 2024 09:22:31 +0000 Subject: [PATCH] Bug 36627: Rename embed method to patron This patch renames the embed method from borrowernumber to patron to fit with the use of 'patron' in the API Signed-off-by: Pedro Amorim --- Koha/ERM/EUsage/CounterLog.pm | 12 ++++++------ Koha/Schema/Result/ErmCounterLog.pm | 11 +++++++++++ api/v1/swagger/definitions/erm_counter_log.yaml | 10 +++++++--- api/v1/swagger/paths/erm_counter_logs.yaml | 2 +- .../ERM/UsageStatisticsDataProvidersCounterLogs.vue | 8 ++++---- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Koha/ERM/EUsage/CounterLog.pm b/Koha/ERM/EUsage/CounterLog.pm index c494fda0e06..4743a028bdc 100644 --- a/Koha/ERM/EUsage/CounterLog.pm +++ b/Koha/ERM/EUsage/CounterLog.pm @@ -32,17 +32,17 @@ Koha::ERM::EUsage::CounterLog - Koha ErmCounterLog Object class =cut -=head3 borrowernumber +=head3 patron -Return the borrower for this counter_file +Return the patron for this counter_file =cut -sub borrowernumber { +sub patron { my ($self) = @_; - my $borrowers_rs = $self->_result->borrowernumber; - return unless $borrowers_rs; - return Koha::Patron->_new_from_dbic($borrowers_rs); + my $patrons_rs = $self->_result->patron; + return unless $patrons_rs; + return Koha::Patron->_new_from_dbic($patrons_rs); } diff --git a/Koha/Schema/Result/ErmCounterLog.pm b/Koha/Schema/Result/ErmCounterLog.pm index 4927a96aead..2e7fa31f1f6 100644 --- a/Koha/Schema/Result/ErmCounterLog.pm +++ b/Koha/Schema/Result/ErmCounterLog.pm @@ -181,6 +181,17 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-11-30 17:43:57 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fEB6HZDsjTTJVWlnW+y/Ng +__PACKAGE__->belongs_to( + "patron", + "Koha::Schema::Result::Borrower", + { borrowernumber => "borrowernumber" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); sub koha_object_class { 'Koha::ERM::EUsage::CounterLog'; diff --git a/api/v1/swagger/definitions/erm_counter_log.yaml b/api/v1/swagger/definitions/erm_counter_log.yaml index 097b08d934c..572f78b6e1b 100644 --- a/api/v1/swagger/definitions/erm_counter_log.yaml +++ b/api/v1/swagger/definitions/erm_counter_log.yaml @@ -11,10 +11,9 @@ properties: - integer - "null" borrowernumber: - type: object - description: patron object + description: borrowernumber of the counter log type: - - object + - integer - "null" importdate: type: string @@ -35,6 +34,11 @@ properties: type: - integer - "null" + patron: + description: patron object for the importer + type: + - object + - "null" additionalProperties: false required: diff --git a/api/v1/swagger/paths/erm_counter_logs.yaml b/api/v1/swagger/paths/erm_counter_logs.yaml index 22893b3859f..db7c35e0596 100644 --- a/api/v1/swagger/paths/erm_counter_logs.yaml +++ b/api/v1/swagger/paths/erm_counter_logs.yaml @@ -21,7 +21,7 @@ items: type: string enum: - - borrowernumber + - patron - $ref: "../swagger.yaml#/parameters/match" - $ref: "../swagger.yaml#/parameters/order_by" - $ref: "../swagger.yaml#/parameters/page" diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsDataProvidersCounterLogs.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsDataProvidersCounterLogs.vue index 624b792cf95..ee290b24701 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsDataProvidersCounterLogs.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/UsageStatisticsDataProvidersCounterLogs.vue @@ -41,7 +41,7 @@ export default { tableOptions: { columns: this.getTableColumns(), options: { - embed: "borrowernumber", + embed: "patron", }, url: () => this.table_url(), table_settings: this.counter_log_table_settings, @@ -139,9 +139,9 @@ export default { { title: __("Imported by"), render: function (data, type, row, meta) { - const borrower = row.borrowernumber - const importer = borrower - ? `${borrower.firstname} ${borrower.surname}` + const { patron } = row + const importer = patron + ? `${patron.firstname} ${patron.surname}` : this.$__("Cronjob") return importer }, -- 2.39.3 (Apple Git-146)