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

Report email stats enhacement #7214

wants to merge 14 commits into
base: staging


3 participants
Copy link

kuzmany commented Feb 4, 2019

Please be sure you are submitting this against the staging branch.

Bug fix?
New feature?
Automated tests included?
Related user documentation PR URL
Related developer documentation PR URL
Issues addressed (#s or URLs)
BC breaks?


This PR change logic to generate email stats (Data Source: Email).

Before update the emails are listed with date_added limit and numbers (sent, read, unsubscribed) are loaded global for all period. This a lot of users make confused.


  • If Hide date range is enabled - the dater range filter don't apply . Thats what we expect, If I don't see date range forms, then date range cannot be apply to query.
  • Data Source: Email - with date range now loaded emails active from date range and related stats (unsubscribed, ratio, read etc). That means If choose range last month, then I will see just emails and stats to that related month.

With enabled Hide date range SQL use the global dat from emails table (sent_count, read_count ...)
With disable Hide date range SQL query create inner JOIN to other huge tables (page_hits, email_stats..) with date range limit. This prevent load the large table more times.

Steps to test this PR:

  1. Load up this PR or load to you local enviroment with stats
  2. Jus retest both case
  • If Hide date range is enabled/disabled
  • If enabled - then try load custom date range and see If stats are related and what do you expect from that range
    If disabled - see global stats to each email
    Also try filters for both state


List deprecations along with the new alternative:

List backwards compatibility breaks:

kuzmany added some commits Feb 4, 2019

Revert "Init commit"
This reverts commit b5024e3.

kuzmany added some commits Feb 4, 2019

Hide date range nwo means skip date filter also
All email stats add relative to date rang If selected

@kuzmany kuzmany added Ready To Test and removed WIP labels Feb 5, 2019

kuzmany added some commits Feb 5, 2019

@kuzmany kuzmany added this to the 2.16.0 milestone Feb 5, 2019

Copy link

npracht left a comment

I think there is an issue, i'm running the creation of a new report on a DB with data and the creation of the report is running still running for ages.
Here is the query:

SELECT SUM(DISTINCT e.sent_count) as sent_count, SUM(DISTINCT e.read_count) as read_count, count(CASE WHEN and dnc.reason = 1 THEN 1 ELSE null END) as unsubscribed, count(CASE WHEN and dnc.reason = 2 THEN 1 ELSE null END) as bounced FROM emails e LEFT JOIN emails vp ON = e.variant_parent_id INNER JOIN email_stats es ON = es.email_id LEFT JOIN categories c ON = e.category_id LEFT JOIN (SELECT COUNT(cut2.channel_id) AS trackable_count, SUM(cut2.hits) AS hits, SUM(cut2.unique_hits) AS unique_hits, cut2.channel_id FROM channel_url_trackables cut2 WHERE = 'email' GROUP BY cut2.channel_id) cut ON = cut.channel_id LEFT JOIN lead_donotcontact dnc ON = dnc.channel_id AND'email' WHERE es.date_sent IS NULL OR (es.date_sent BETWEEN '2019-01-05 23:00:00' AND '2019-02-06 09:09:14')

kuzmany added some commits Feb 6, 2019

Copy link

npracht left a comment

Tested and i confirm it works. this is such an amazing improvement to follow email stats in time !!

@npracht npracht added this to Ready to Test (first time) in Mautic 2 via automation Feb 7, 2019

Mautic 2 automation moved this from Ready to Test (first time) to Changes Requested / Review Feb 8, 2019


This comment has been minimized.

Copy link

johbuch commented Feb 26, 2019

@kuzmany seems much better with your last commit ! thanks ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.