Skip to content

Commit

Permalink
Remove xTEDCANID and xTEDCNID from Tender and Bid
Browse files Browse the repository at this point in the history
Fixes #15
  • Loading branch information
Georgiana Bere committed Apr 3, 2020
1 parent 89c1107 commit 1513ba7
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 58 deletions.
1 change: 0 additions & 1 deletion api/serializers/bid.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const lotSerializer = require('./lot');

bidSerializer.formatBid = function (bid) {
const formattedBid = _.pick(bid, ['isWinning', 'isSubcontracted', 'xYearApproximated']);
formattedBid.TEDCANID = bid.xTEDCANID;
formattedBid.value = _.get(bid, 'price.netAmountEur') || undefined;
formattedBid.xAmountApproximated = _.get(bid, 'price.xAmountApproximated');
return formattedBid;
Expand Down
1 change: 0 additions & 1 deletion api/serializers/tender.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ tenderSerializer.formatTender = function (tender) {
const formattedTender = _.pick(tender, ['id', 'title', 'titleEnglish', 'description', 'sources',
'isCoveredByGpa', 'isFrameworkAgreement', 'procedureType', 'year', 'country', 'isDirective', 'xYearApproximated']);
formattedTender.isEUFunded = tender.xIsEuFunded;
formattedTender.TEDCNID = tender.xTEDCNID;
formattedTender.isDirective = tender.xIsDirective;
formattedTender.finalValue = _.get(tender, 'finalPrice.netAmountEur') || undefined;
formattedTender.xAmountApproximated = _.get(tender, 'finalPrice.xAmountApproximated');
Expand Down
6 changes: 0 additions & 6 deletions api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1556,9 +1556,6 @@ definitions:
isWinning:
type: boolean
description: Did this bid won the lot?
TEDCANID:
type: string
description: ID of the Contract Award Notice on ted.europa.eu
isSubcontracted:
type: boolean
description: Did the winner subcontract another company for this bid?
Expand Down Expand Up @@ -1629,9 +1626,6 @@ definitions:
items:
type: string
description: URL to tender source
TEDCNID:
type: string
description: ID of the Contract Notice on ted.europa.eu
title:
type: string
description: Title of the tender
Expand Down
6 changes: 0 additions & 6 deletions extractors/bid.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ function extractBid(bidAttrs, tenderAttrs, lotAttrs) {
robustPrice: priceExtractor.extractPrice(bidAttrs.robustPrice),
xCountry: _.get(tenderAttrs, 'ot.country') || tenderAttrs.country,
xYear: extractYear(lotAttrs.awardDecisionDate),
xTEDCANID: _
.chain((tenderAttrs.publications || []))
.filter({ formType: 'CONTRACT_AWARD' })
.head()
.get('sourceId')
.value(),
sources: extractSources(tenderAttrs.publications),
};
}
Expand Down
4 changes: 0 additions & 4 deletions extractors/tender.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ function extractTender(tenderAttrs, indicators = [], publications = []) {
indicators: _
.filter(indicators, { relatedEntityId: tenderAttrs.id })
.map((indicatorAttrs) => indicatorExtractor.extractIndicator(indicatorAttrs)),
xTEDCNID: _.get(
_.head(_.filter(publications, { formType: 'CONTRACT_NOTICE' })),
'sourceId',
),
year: extractYear(publications),
sources: extractSources(publications),
};
Expand Down
19 changes: 19 additions & 0 deletions migrations/m20200403_101942_remove_xTEDCNID_from_tender.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";
exports.name = "remove xTEDCNID from tender";


exports.up = (db) => (
db.class.get('Tender')
.then((Tender) => Tender.property.drop('xTEDCNID'))
);

exports.down = (db) => (
db.class.get('Tender')
.then((Tender) =>
Tender.property.create([
{
name: 'xTEDCNID',
type: 'String',
},
]))
);
18 changes: 18 additions & 0 deletions migrations/m20200403_103410_remove_xTEDCANID_from_Bid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"use strict";
exports.name = "remove xTEDCANID from Bid";

exports.up = (db) => (
db.class.get('Bid')
.then((Bid) => Bid.property.drop('xTEDCANID'))
);

exports.down = (db) => (
db.class.get('Bid')
.then((Bid) =>
Bid.property.create([
{
name: 'xTEDCANID',
type: 'String',
},
]))
);
23 changes: 0 additions & 23 deletions test/extractors/bid.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,6 @@ const test = require('ava');
const bidExtractor = require('./../../extractors/bid');
const fixtures = require('./../fixtures');

test('extractBid extracts contract award notice id from publications', async (t) => {
const publication = await fixtures.build('rawContractAwardNotice');
const rawBid = await fixtures.build('rawBid');
const rawTender = await fixtures.build('rawTender', {
publications: [publication],
});
t.is(
bidExtractor.extractBid(rawBid, rawTender, {}).xTEDCANID,
publication.sourceId,
);
});

test('extractBid returns null if there is no publication', async (t) => {
const rawBid = await fixtures.build('rawBid');
const rawTender = await fixtures.build('rawTender', {
publications: [],
});
t.is(
bidExtractor.extractBid(rawBid, rawTender, {}).xTEDCANID,
undefined,
);
});

test('extractBid extracts year from lots award decision date', async (t) => {
const rawBid = await fixtures.build('rawBid');
const year = 2015;
Expand Down
17 changes: 0 additions & 17 deletions test/extractors/tender.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ const test = require('ava');
const tenderExtractor = require('./../../extractors/tender');
const fixtures = require('./../fixtures');

test('extractTender extracts contract notice id from publications', async (t) => {
const publication = await fixtures.build('rawContractNotice');
const rawTender = await fixtures.build('rawTender');
t.is(
tenderExtractor.extractTender(rawTender, [], [publication]).xTEDCNID,
publication.sourceId,
);
});

test('extractTender returns null if there is no publication', async (t) => {
const rawTender = await fixtures.build('rawTender');
t.is(
tenderExtractor.extractTender(rawTender, [], []).xTEDCNID,
undefined,
);
});

test('extractTender extracts sources from contract notice publications', async (t) => {
const publication = await fixtures.build('rawContractNotice');
const rawTender = await fixtures.build('rawTender');
Expand Down

0 comments on commit 1513ba7

Please sign in to comment.