@merkl/api 0.20.59 → 0.20.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ export class OpportunityRepository {
|
|
11
11
|
static #transformQueryToPrismaFilters(query) {
|
12
12
|
const { page: _page, items: _items, ...filters } = query;
|
13
13
|
//TODO: abstract away query to not be strictly equal to controller
|
14
|
+
const now = moment().unix();
|
14
15
|
const chainIds = query.chainId?.split(",").map(n => Number.parseInt(n));
|
15
16
|
const actions = query.action?.split(",");
|
16
17
|
const status = query.status?.split(",");
|
@@ -65,17 +66,40 @@ export class OpportunityRepository {
|
|
65
66
|
: {
|
66
67
|
AND: search?.map(keyword => ({
|
67
68
|
OR: [
|
69
|
+
//IDs
|
68
70
|
{ id: { contains: keyword, mode: "insensitive" } },
|
69
71
|
{ name: { contains: keyword, mode: "insensitive" } },
|
70
72
|
{ identifier: { contains: keyword, mode: "insensitive" } },
|
71
73
|
{ explorerAddress: { contains: keyword, mode: "insensitive" } },
|
74
|
+
{ Campaigns: { some: { campaignId: { contains: keyword, mode: "insensitive" } } } },
|
75
|
+
{ Campaigns: { some: { id: { contains: keyword, mode: "insensitive" } } } },
|
76
|
+
//ERC20,CLAMM,...
|
72
77
|
{ type: { contains: keyword, mode: "insensitive" } },
|
78
|
+
//Protocol
|
73
79
|
{ MainProtocol: { name: { contains: keyword, mode: "insensitive" } } },
|
74
80
|
{ mainProtocolId: { contains: keyword, mode: "insensitive" } },
|
81
|
+
//Token
|
75
82
|
{ Tokens: { some: { name: { contains: keyword, mode: "insensitive" } } } },
|
76
83
|
{ Tokens: { some: { symbol: { contains: keyword, mode: "insensitive" } } } },
|
77
|
-
{
|
78
|
-
|
84
|
+
{ Tokens: { some: { address: { contains: keyword, mode: "insensitive" } } } },
|
85
|
+
//Match reward tokens only if campaign is live
|
86
|
+
{
|
87
|
+
Campaigns: {
|
88
|
+
some: {
|
89
|
+
endTimestamp: { gte: now },
|
90
|
+
RewardToken: {
|
91
|
+
OR: [
|
92
|
+
{
|
93
|
+
symbol: { contains: keyword, mode: "insensitive" },
|
94
|
+
},
|
95
|
+
{
|
96
|
+
address: { contains: keyword, mode: "insensitive" },
|
97
|
+
},
|
98
|
+
],
|
99
|
+
},
|
100
|
+
},
|
101
|
+
},
|
102
|
+
},
|
79
103
|
{ Chain: { name: { contains: keyword, mode: "insensitive" } } },
|
80
104
|
],
|
81
105
|
})),
|