-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat: Show Building if a segment is new or updated but not yet rebuilt #14431
base: 6.x
Are you sure you want to change the base?
Conversation
I have some other work pending that hopefully I can follow up with later. Specifically there is one where I made |
Will check tests in some time. Looks like I was gonna add test for the class changes in the AJX and forgot! Will look at it when I can but welcome feedback in the interim |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 6.x #14431 +/- ##
============================================
- Coverage 63.65% 63.65% -0.01%
- Complexity 34640 34642 +2
============================================
Files 2277 2277
Lines 103625 103629 +4
============================================
- Hits 65965 65963 -2
- Misses 37660 37666 +6
|
61cf652
to
44c6718
Compare
Fixed the tests and added missing CSS classes test. |
Hey @driskell, could you rebase your branch and change the target to 6.x? 5.2 is receiving only bug fixes at this time |
44c6718
to
1d9a78d
Compare
Ah is there no 5.3 due then? (I targeted 5.x not 5.2) I rebased to 6.x anyway but it looks like it cleanly applies to both with exception of 1 line in the AjaxController so easy to cherry if there was going to be a 5.3 and it was deemed useful. |
@driskell We're moving all new enhancements and features to 6.x without 5.3. As the release calendar is many months late, Mautic will skip some versions until we get up to date :) |
@driskell Re. the failing tests, could you check PHUnit? |
I think bogus - looks like a random fail due to time or something and the baseline never was changed. I’ll push again to force rerun as perhaps it ran it on the push before I changed the base and didn’t rerun |
1d9a78d
to
36d9f12
Compare
@andersonjeccel Looks good now! btw do you know is there a way for me to get onto the development slack? I think the register is locked for external users at the moment. |
I think the needs-rebase tag can be removed now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@driskell btw, could you ping me in the Mautic Slack? I'm there as |
I tried to register but I think searching forums there's an invite limit that might be reached. If I click https://mau.tc/slack-invite it only allows Mautic domains for the email registration. |
@driskell Asked the lead to update, could you try again using the same link? |
@escopecz Would you like to finish code review? |
/** @var ListModel $model */ | ||
$model = $this->getModel('lead.list'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This model is already available via controller action DI and can be removed
/** @var ListModel $model */ | |
$model = $this->getModel('lead.list'); |
if ($building) { | ||
$html = $this->translator->trans( | ||
'mautic.lead.list.building', | ||
['%count%' => $leadCount] | ||
); | ||
} else { | ||
$html = $this->translator->trans( | ||
'mautic.lead.list.viewleads_count', | ||
['%count%' => $leadCount] | ||
), | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can avoid some duplicated code here:
$message = $building ? 'mautic.lead.list.building' : 'mautic.lead.list.viewleads_count';
$html = $this->translator->trans($message, ['%count%' => $leadCount]);
{% if (item.getFilters() is not empty and (item.lastBuiltDate is null or (item.dateModified is not null and item.dateModified.timestamp >= item.lastBuiltDate.timestamp))) %} | ||
<span size="sm" class="label label-info col-count" data-id="{{ item.id }}"> | ||
<a href="{{ path('mautic_contact_index', {'search': 'mautic.lead.lead.searchcommand.list'|trans ~ ':' ~ item.alias}) }}" | ||
data-toggle="ajax">{{ 'mautic.lead.list.building'|trans({'%count%': leadCounts[item.id]}) }}</a> | ||
</span> | ||
{% else %} | ||
<span size="sm" class="label label-gray col-count" data-id="{{ item.id }}"> | ||
<a href="{{ path('mautic_contact_index', {'search': 'mautic.lead.lead.searchcommand.list'|trans ~ ':' ~ item.alias}) }}" | ||
data-toggle="ajax">{{ 'mautic.lead.list.viewleads_count'|trans({'%count%': leadCounts[item.id]}) }}</a> | ||
</span> | ||
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see this is the same condition as in the controller. As it uses only values that are already known to the LeadList
entity, let's make a method there:
public function needsRebuild(): bool
{
return count($leadList->getFilters())
&& (
null === $leadList->getLastBuiltDate()
|| $leadList->getDateModified() >= $leadList->getLastBuiltDate()
);
}
Then you can call it in the controller as well as here and avoid the duplicated HTML code:
{% if (item.getFilters() is not empty and (item.lastBuiltDate is null or (item.dateModified is not null and item.dateModified.timestamp >= item.lastBuiltDate.timestamp))) %} | |
<span size="sm" class="label label-info col-count" data-id="{{ item.id }}"> | |
<a href="{{ path('mautic_contact_index', {'search': 'mautic.lead.lead.searchcommand.list'|trans ~ ':' ~ item.alias}) }}" | |
data-toggle="ajax">{{ 'mautic.lead.list.building'|trans({'%count%': leadCounts[item.id]}) }}</a> | |
</span> | |
{% else %} | |
<span size="sm" class="label label-gray col-count" data-id="{{ item.id }}"> | |
<a href="{{ path('mautic_contact_index', {'search': 'mautic.lead.lead.searchcommand.list'|trans ~ ':' ~ item.alias}) }}" | |
data-toggle="ajax">{{ 'mautic.lead.list.viewleads_count'|trans({'%count%': leadCounts[item.id]}) }}</a> | |
</span> | |
{% endif %} | |
<span size="sm" class="label label-{{ item.needsRebuild() ? "info" : "grey" }} col-count" data-id="{{ item.id }}"> | |
<a href="{{ path('mautic_contact_index', {'search': 'mautic.lead.lead.searchcommand.list'|trans ~ ':' ~ item.alias}) }}" | |
data-toggle="ajax">{{ (item.needsRebuild() ? 'mautic.lead.list.building' : 'mautic.lead.list.viewleads_count')|trans({'%count%': leadCounts[item.id]}) }}</a> | |
</span> |
I'm not sure if this is possible in Twig but you get the idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep should be able to call item.needsRebuild()
mautic.segment.last_built="Last built" | ||
mautic.segment.last_built_duration_ms="Build time (milliseconds)" | ||
mautic.segment.not_built="Not yet built" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it needs removing, snuck in from a previous POC I think where it had an additional status before the build begin, but in review on our side it felt unnecessary to expose the fact that builds run on cron at specific times
Thanks for the review @escopecz - all need some changes to clear them up and will aim to look at that in next couple days. |
Description
When creating a new segment with filters, it displays immediately "No Contacts". This can be confusing to new users as it does not indicate there is an action waiting to build the new segment. Additionally, once build begins, you will see "123 Contacts" - however, the build may not be finished yet. The only way a user can know it is finished is to keep refreshing the page until the count does not change for a minute. It's not really easy to know if it's completed.
Similarly, when editing a segment, for example if you realised you captured too many due to a typo, after saving you just see the same contact count. There is no indication that a rebuild is waiting that might substantially change the count (even potentially reducing it to "No Contacts"). Neither is there indication of progress or when it completes. So again you are left refreshing the page waiting for it to stop changing. In cases where the change is 0 it is then even more difficult as you cannot know if it just didn't get around to rebuilding yet or if it did rebuild but it was 0 change because of an error in your filters.
This PR adds in additional statuses, bringing the list to:
Screenshot for a new segment:
After
mautic:segments:update
passes over it:After it is modified by a user:
This then returns to the previous screen after
mautic:segments:update
passes over it.📋 Steps to test this PR:
mautic:segments:update
. It will now display No Contacts or X Contacts depending on the filters.mautic:segments:update
. It will now display No Contacts or X Contacts depending on the filters.I did deprecate the
Mautic\LeadBundle\Entity\LeadList::initializeLastBuiltDate
as we need to allownull
last built date for new segments. Previously it would be set to a last built date of now for a new segment which was incorrect. The field was always nullable though so it's hard to say how bad a BC change this would be. I left the method in place as it was public, and marked it@deprecated
.My sponsoring organisation here is Other Media