Skip to content

Commit

Permalink
Fix winner parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
reyraa committed Nov 15, 2023
1 parent 0be71ac commit 1ac62e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ const getAnchors = async (params = {}) => {

let anchorData = [];

const { winner, ...restParams } = params;
const { winner, search, ...restParams } = params;

if (winner !== undefined) {
if (winner === 1) {
const response = await badgesTable.find(
{ ...restParams, limit: restParams.limit || 10 },
['anchorID'],
Expand All @@ -66,18 +66,15 @@ const getAnchors = async (params = {}) => {
);
anchorData = res.filter(anchor => anchor);
} else {
if (restParams.search) {
const { search, ...remParams } = restParams;
params = remParams;

params.search = {
if (search) {
restParams.search = {
property: 'name',
pattern: search,
};
}

anchorData = await anchorsTable.find(
{ ...params, limit: params.limit || 10 },
{ ...restParams, limit: restParams.limit || 10 },
['anchorID', 'name', 'album', 'artists', 'spotifyId', 'appleMusicId', 'createdAt', 'submitter'],
);
}
Expand Down Expand Up @@ -110,7 +107,7 @@ const getAnchors = async (params = {}) => {
data,
meta: {
count: data.length,
offset: parseInt(params.offset, 10) || 0,
offset: parseInt(restParams.offset, 10) || 0,
total,
},
};
Expand Down
1 change: 1 addition & 0 deletions services/gateway/sources/version3/anchors.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
senderAddress: '=,string',
}],
search: '=,string',
winner: '=,number',
limit: '=,number',
offset: '=,number',
sort: '=,string',
Expand Down

0 comments on commit 1ac62e4

Please sign in to comment.