@merkl/api 0.17.32 → 0.17.33

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.
@@ -209,7 +209,11 @@ export class OpportunityService {
209
209
  const opportunity = await OpportunityRepository.findUnique(id);
210
210
  if (!opportunity)
211
211
  throw new NotFoundError();
212
- const firstCampaign = opportunity?.Campaigns.filter(campaign => campaignId ? campaign.campaignId === campaignId : true).sort((a, b) => Number(b.endTimestamp) - Number(a.endTimestamp))[0];
212
+ const sortedCampaigns = opportunity?.Campaigns.filter(campaign => campaignId ? campaign.campaignId === campaignId : true).sort((a, b) => Number(b.endTimestamp) - Number(a.endTimestamp));
213
+ let firstCampaign = sortedCampaigns[0];
214
+ const firstCampaigns = sortedCampaigns.filter(campaign => campaign.startTimestamp <= BigInt(moment().unix()));
215
+ if (firstCampaigns.length >= 0)
216
+ firstCampaign = firstCampaigns[0];
213
217
  return await OpportunityService.createFromCampaign({
214
218
  ...firstCampaign,
215
219
  type: CampaignEnum[firstCampaign.type],