Committer: vtroitsky
LJSUP-12814: Remove duplicate posts from scrollerU trunk/cgi-bin/LJ/Pay/SelfPromo.pm
Modified: trunk/cgi-bin/LJ/Pay/SelfPromo.pm =================================================================== --- trunk/cgi-bin/LJ/Pay/SelfPromo.pm 2012-08-07 12:45:38 UTC (rev 12437) +++ trunk/cgi-bin/LJ/Pay/SelfPromo.pm 2012-08-07 14:04:57 UTC (rev 12438) @@ -739,10 +739,12 @@ Return array of promotion object (for past, current, future) Args: slot - slot to use - index - index of the promo + index - index of the promo, <= 0 (from current element into the past) count - max count of slots, def. 5 + TODO: unique - flag to get unique (by promoted object) promotions only, last by time occurence is used - REQ: index <= 0 + force_active - flag to return undef for current empty promo + REQ: index <= 0, REQ: index + count <= 0 TODO: Add cache scheme =cut @@ -768,8 +770,12 @@ my $limit = abs($count); my $desc = $count > 0 ? 'DESC' : 'ASC'; - my $promos = LJ::Pay::Promotion->find_promotions({ slot => $slot, started_max => time, offset => $offset, limit => $limit, sort => 'started', desc => 'DESC' }); + my $promos = LJ::Pay::Promotion->find_promotions({ slot => $slot, started_max => time, offset => $offset, limit => $limit, sort => 'started', desc => 'DESC', unique => $args{'unique'} }); $promos = [ reverse (@$promos) ] unless $codirection; + + if($args{'force_current'} && $index == 0 && !$promos->[0]->is_active()) { + warn "Force current empty element"; + }; return $promos; }