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

Updated filter function name to make it more logical #2751

Merged
merged 1 commit into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/targeting.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const MAX_DFP_KEYLENGTH = 20;
const TTL_BUFFER = 1000;

// return unexpired bids
export const isBidExpired = (bid) => (bid.responseTimestamp + bid.ttl * 1000 + TTL_BUFFER) > timestamp();
export const isBidNotExpired = (bid) => (bid.responseTimestamp + bid.ttl * 1000 + TTL_BUFFER) > timestamp();

// return bids whose status is not set. Winning bid can have status `targetingSet` or `rendered`.
const isUnusedBid = (bid) => bid && ((bid.status && !includes([BID_TARGETING_SET, RENDERED], bid.status)) || !bid.status);
Expand Down Expand Up @@ -195,7 +195,7 @@ export function newTargeting(auctionManager) {
function getBidsReceived() {
const bidsReceived = auctionManager.getBidsReceived()
.filter(isUnusedBid)
.filter(exports.isBidExpired)
.filter(exports.isBidNotExpired)
;

return getHighestCpmBidsFromBidPool(bidsReceived, getOldestHighestCpmBid);
Expand Down
10 changes: 5 additions & 5 deletions test/spec/unit/core/targeting_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ describe('targeting tests', () => {
amGetAdUnitsStub = sinon.stub(auctionManager, 'getAdUnitCodes').callsFake(function() {
return ['/123456/header-bid-tag-0'];
});
bidExpiryStub = sinon.stub(targetingModule, 'isBidExpired').returns(true);
bidExpiryStub = sinon.stub(targetingModule, 'isBidNotExpired').returns(true);
});

afterEach(() => {
auctionManager.getBidsReceived.restore();
auctionManager.getAdUnitCodes.restore();
targetingModule.isBidExpired.restore();
targetingModule.isBidNotExpired.restore();
});

it('selects the top bid when _sendAllBids true', () => {
Expand Down Expand Up @@ -149,13 +149,13 @@ describe('targeting tests', () => {
amGetAdUnitsStub = sinon.stub(auctionManager, 'getAdUnitCodes').callsFake(function() {
return ['/123456/header-bid-tag-0'];
});
bidExpiryStub = sinon.stub(targetingModule, 'isBidExpired').returns(true);
bidExpiryStub = sinon.stub(targetingModule, 'isBidNotExpired').returns(true);
});

afterEach(() => {
auctionManager.getBidsReceived.restore();
auctionManager.getAdUnitCodes.restore();
targetingModule.isBidExpired.restore();
targetingModule.isBidNotExpired.restore();
});

it('returns targetingSet correctly', () => {
Expand All @@ -171,7 +171,7 @@ describe('targeting tests', () => {
let bidExpiryStub;
let auctionManagerStub;
beforeEach(() => {
bidExpiryStub = sinon.stub(targetingModule, 'isBidExpired').returns(true);
bidExpiryStub = sinon.stub(targetingModule, 'isBidNotExpired').returns(true);
auctionManagerStub = sinon.stub(auctionManager, 'getBidsReceived');
});

Expand Down
4 changes: 2 additions & 2 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ window.apntag = {
describe('Unit: Prebid Module', function () {
let bidExpiryStub;
before(() => {
bidExpiryStub = sinon.stub(targetingModule, 'isBidExpired').callsFake(() => true);
bidExpiryStub = sinon.stub(targetingModule, 'isBidNotExpired').callsFake(() => true);
});

after(function() {
$$PREBID_GLOBAL$$.adUnits = [];
targetingModule.isBidExpired.restore();
targetingModule.isBidNotExpired.restore();
});

describe('getAdserverTargetingForAdUnitCodeStr', function () {
Expand Down