We ran into two issues which we believe this patch solves.

First, when viewing a campaign (admin/content/simpleads_campaigns/[nid]), the "Clicks Left" and "Impressions Left" columns are misleading because they only include the clicks and impressions that happened on previous days. This causes confusion for our clients, because they don't see the click and impression numbers changing in real time. This one is mostly a display issue that causes confusion for the client (and by the look of the issue queue for this module, it causes confusion for a lot of devs as well).

Second, and most importantly, this bug allows campaigns to exceed their click and impression limits. In the following situation, the module will wrongly continue to show ads from the given campaign:

Campaign A has a limit of 1000 clicks. As of the end of day yesterday, it only had 2 clicks left. If it was working properly, when I receive my second click today around 1am, then the campaign is complete and the ad should stop showing. However, since the code only counts the clicks and impressions at the end of each day, this ad could receive 100 more clicks today and not be disabled until tonight at midnight. This is obviously not desired behavior.

The following patch makes the same change to the two methods which count the current number of clicks and impressions. Happily, this solves both problems described above. The methods are _simpleads_campaigns_count_ad_impressions() and _simpleads_campaigns_count_ad_clicks().

Previously, those methods would do a simple select from the simpleads_stats table which holds the aggregated data for previous days. We changed them to use a more complex select query which combines that information with the information for the current day. This means, every unique impression or unique click is reflected in real-time when viewing the campaign in the admin interface and when the campaign reaches the impression or click threshold the campaign will immediately end.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kennywyland created an issue. See original summary.

kennywyland’s picture

The following patch makes the same change to the two methods which count the current number of clicks and impressions. Happily, this solves both problems described above. The methods are _simpleads_campaigns_count_ad_impressions() and _simpleads_campaigns_count_ad_clicks().

Previously, those methods would do a simple select from the simpleads_stats table which holds the aggregated data for previous days. We changed them to use a more complex select query which combines that information with the information for the current day. This means, every unique impression or unique click is reflected in real-time when viewing the campaign in the admin interface and when the campaign reaches the impression or click threshold the campaign will immediately end.

kennywyland’s picture

This is my first time submitting a patch, so I'm not sure if I've done it correctly, since it doesn't appear the way other patch files look in comment threads. :/

minnur’s picture

Status: Active » Closed (won't fix)