[Bps-public-commit] rtx-calendar branch allow-custom-field-based-events updated. 1.05-12-g7b22f4f

BPS Git Server git at git.bestpractical.com
Thu Aug 24 17:37:12 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rtx-calendar".

The branch, allow-custom-field-based-events has been updated
       via  7b22f4f1274e65c3ad6a3eba6ee703c7b11431f7 (commit)
       via  6207d7547be40a154b30a01ec05f2aca291a5e22 (commit)
       via  262d72628e5d4cbe0d06b7e147afc667ae2d074c (commit)
      from  43140bd7ab6cd151d3ab5ec8b96b43d29f03136b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 7b22f4f1274e65c3ad6a3eba6ee703c7b11431f7
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Thu Aug 24 14:36:36 2023 -0300

    Small code formatting for better readability

diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index b0eb038..dd3a6fd 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -100,6 +100,7 @@ sub FindTickets {
                 my $DateObj = $Date . "Obj";
                 $dateindex = LocalDate( $Ticket->$DateObj->Unix );
             }
+
             push @{ $Tickets{$dateindex } },
                 $Ticket
 

commit 6207d7547be40a154b30a01ec05f2aca291a5e22
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Thu Aug 24 14:18:47 2023 -0300

    Refactor Custom Field checking for the Calendar
    
    Remove pre-loading of all Custom Fields, and instead only load the
    Custom Fields that are used by the Calendar, declared on the Format
    attribute.
    
    Also, update the way that the date content of the custom field was parsed
    for consistency. Instead of using regex, we now load it to a Date Object
    and parse it with LocalDate.

diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index cbd1903..b0eb038 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -79,9 +79,23 @@ sub FindTickets {
             if ($Date =~ /^CF\./){
                 my $cf = $Date;
                 $cf =~ s/^CF\.\{(.*)\}/$1/;
-                $dateindex = $Ticket->FirstCustomFieldValue($cf);
-                next unless $dateindex;
-                $dateindex =~ s/(.*) (.*)/$1/;
+
+                my $CFDateValue = $Ticket->FirstCustomFieldValue($cf);
+                next unless $CFDateValue;
+                my $CustomFieldObj = RT::CustomField->new($CurrentUser);
+                $CustomFieldObj->LoadByName( Name => $cf );
+                my $CustomFieldObjType = $CustomFieldObj->Type;
+                my $DateObj            = RT::Date->new($CurrentUser);
+                if ( $CustomFieldObjType eq 'Date' ) {
+                    $DateObj->Set(
+                        Format   => 'unknown',
+                        Value    => $CFDateValue,
+                        Timezone => 'utc'
+                    );
+                } else {
+                    $DateObj->Set( Format => 'ISO', Value => $CFDateValue );
+                }
+                $dateindex = LocalDate( $DateObj->Unix );
             } else {
                 my $DateObj = $Date . "Obj";
                 $dateindex = LocalDate( $Ticket->$DateObj->Unix );

commit 262d72628e5d4cbe0d06b7e147afc667ae2d074c
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Thu Aug 24 14:05:03 2023 -0300

    Add comment about $dateindex to explain how it's used
    
    When we added the date and date time Custom Field support to the
    calendar, we added a bit of complexity to the code and needed to
    add use of a new variable, $dateindex, to extract the correct date
    from the Custom Field value and index the Ticket into the correct
    date bucket.

diff --git a/lib/RTx/Calendar.pm b/lib/RTx/Calendar.pm
index e0b9390..cbd1903 100644
--- a/lib/RTx/Calendar.pm
+++ b/lib/RTx/Calendar.pm
@@ -71,6 +71,10 @@ sub FindTickets {
 
         # How to find the LastContacted date ?
         for my $Date (@$Dates) {
+
+            # $dateindex is the date to use as key in the Tickets Hash
+            # in the YYYY-MM-DD format
+            # Tickets are then groupd by date in the %Tickets hash
             my $dateindex;
             if ($Date =~ /^CF\./){
                 my $cf = $Date;

-----------------------------------------------------------------------

Summary of changes:
 lib/RTx/Calendar.pm | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
rtx-calendar


More information about the Bps-public-commit mailing list