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

Add routine for updating smartgroups, currently handling datepicker conversion #13395

Merged
merged 1 commit into from
Jan 10, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Convert fields from smart groups using grant date fields to reflect new datepicker format

Before

As of #13211 the fields are converted in the search but pre-existing smart groups still use the old format for these dates

After

On upgrade the groups are updated to the new format

Technical Details

Merge in conjuction with #13211

This ties in with the larger effort in https://lab.civicrm.org/dev/core/issues/561 to remove jcalendar. I started down the path of on-form conversions but decided in the long run it would be cleaner to upgrade the groups - this approach could probably safely be applied to some already updated ones like lybunt custom search in order to remove cruft.

I think the upgrade part could be iterated on for more improvements. Campaign Search seems like the obvious next form for daterange updates

Comments

@seamuslee001 @monishdeb @mattwire

@civibot
Copy link

civibot bot commented Jan 4, 2019

(Standard links)

@civibot civibot bot added the master label Jan 4, 2019
@colemanw
Copy link
Member

colemanw commented Jan 7, 2019

@eileenmcnaughton do we need to convert all advance search components to datepicker within a single upgrade cycle for best results? If so, this is the perfect time of month to start on that project.

@eileenmcnaughton
Copy link
Contributor Author

@colemanw we don't need to do them all at once but when we convert the fields we do need to do this - I'm not seeing this as something to do all in one release both from a volume and a risk POV

public function upgrade_5_11_alpha1($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
$this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', $rev);
}
Copy link
Member

Choose a reason for hiding this comment

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

This is excellent work @eileenmcnaughton. I have one nitpick about the design. The way you've done it here, the addTask function passes a version number to updateSmartGroups which then relies on the data in getSmartGroupConversions to figure out what to do. That's a bit hard to grok and seems like it might cause trouble for future devs trying to figure out and extend what you've done. Since the addTask function can accept a variable number of arguments, I'd suggest passing in whatever's needed directly, e.g.

    $this->addTask('Update grant smart groups for datepicker', 'updateSmartGroups', $rev, [
      'function' => 'datepickerConversion',
      'fields' => [
        'grant_application_received_date',
        'grant_decision_date',
        'grant_money_transfer_date',
        'grant_due_date'
      ]
    ]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@colemanw yeah I guess so - I just thought it would create one array where we could kinda track what had been done when

@colemanw colemanw merged commit 560a6ae into civicrm:master Jan 10, 2019
@eileenmcnaughton eileenmcnaughton deleted the datepicker-update branch January 10, 2019 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants