Skip to content

Conversation

@nikoshell
Copy link
Contributor

No description provided.

@nikoshell nikoshell requested review from artcz and clytaemnestra June 25, 2025 16:56
@europython-society
Copy link
Member

Preview available

Key Value
url https://ep2025-jobs-order.ep-preview.click
last update 2025-06-25T17:00:33.069Z

Comment on lines +60 to +71
const sponsorsWithJobs = sponsors
.filter((sponsor) => sponsor.data.jobs && sponsor.data.jobs.length > 0)
.sort((a, b) => {
const aTierIndex = tiers.indexOf(a.data.tier as typeof tiers[number]);
const bTierIndex = tiers.indexOf(b.data.tier as typeof tiers[number]);
// If tier not found in array, put it at the end
const aIndex = aTierIndex === -1 ? tiers.length : aTierIndex;
const bIndex = bTierIndex === -1 ? tiers.length : bTierIndex;
return aIndex - bIndex;
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a JS developer, but this looks complicated to me - I think we can assume that each sponsor has a tier assigned. Otherwise we wouldn't be able to create one, no?

In that case, I think something as simple as sponsors.filter((s) => s.data.jobs.length).sort((a, b) => tiers.indexOf(a.data.tier) - tiers.indexOf(b.data.tier)); might work (I didn't try to run it, I'm guessing here) and is more readable, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We care only about sponsors with tier which allows to job posts. Array of tiers is shorter then all tiers that we have.

@nikoshell nikoshell merged commit b1360e7 into ep2025 Jun 25, 2025
7 checks passed
@nikoshell nikoshell deleted the ep2025-jobs-order branch June 25, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants