Skip to content

Commit

Permalink
Refs #33623: Rush upgrades - add support for old resource
Browse files Browse the repository at this point in the history
  • Loading branch information
soarer1004 committed Dec 12, 2024
1 parent 3cd8f54 commit 501ebe6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/api/extensions/budsies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,39 @@ module.exports = ({ config, db }) => {
});

budsiesApi.get('/plushies/rush-upgrades', async (req, res) => {
if (req.query.productId === undefined) {
apiStatus(res, 'The field productId is required', 400);
}

const query = {
index: config.elasticsearch.index,
type: 'rush_upgrade',
body: {
query: {
terms: {
'product_id': Array.isArray(req.query.productId) ? req.query.productId : [req.query.productId]
}
}
}
};

try {
const response = await es.search(query)
const hits = response.body ? response.body.hits : response.hits;

const rushUpgrades = hits.hits.map((hit) => {
delete hit._source.tsk;
return hit._source;
});

apiStatus(res, rushUpgrades);
} catch (error) {
console.log(error);
apiStatus(res, error.toString(), error.code);
}
});

budsiesApi.get('/plushies/products-rush-upgrades', async (req, res) => {
const query = {
index: config.elasticsearch.index,
type: 'rush_upgrade',
Expand Down

0 comments on commit 501ebe6

Please sign in to comment.