Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make tiers ignore object property orders #87

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@
}: GithubSponsorsToMarkdownOptions) {
const logger = verbose ? console.log.bind(console) : undefined;
const sponsorshipNodes = await getSponsorshipsAsMaintainer({ logger, login });
const tiersSorted = Object.entries(tiers).sort(
([a], [b]) => tiers[b].minimum - tiers[a].minimum

Check warning on line 19 in src/index.ts

View check run for this annotation

Codecov / codecov/patch

src/index.ts#L18-L19

Added lines #L18 - L19 were not covered by tests
);

const sponsorshipsSorted = sponsorshipNodes
.filter((node) => !node.isOneTimePayment)
.sort((a, b) => b.sponsorEntity.login.localeCompare(a.sponsorEntity.login));
.sort((a, b) => a.sponsorEntity.login.localeCompare(b.sponsorEntity.login));

Check warning on line 24 in src/index.ts

View check run for this annotation

Codecov / codecov/patch

src/index.ts#L24

Added line #L24 was not covered by tests

logger?.(
"Sponsorships, sorted:",
JSON.stringify(sponsorshipsSorted, null, 4)
);
const tierGroups = groupSponsorships(sponsorshipsSorted, tiers);
const tierGroups = groupSponsorships(sponsorshipsSorted, tiersSorted);

Check warning on line 30 in src/index.ts

View check run for this annotation

Codecov / codecov/patch

src/index.ts#L30

Added line #L30 was not covered by tests
const width = `${Math.floor(100 / Object.keys(tierGroups).length)}%`;

const tierGroupsSorted = Object.fromEntries(
Expand Down Expand Up @@ -80,10 +83,9 @@

function groupSponsorships(
sponsorships: SponsorshipNode[],
tiers: Record<string, SponsorshipTier>
tierEntries: [string, SponsorshipTier][]
) {
const tierGroups: Record<string, SponsorshipDescription[]> = {};
const tierEntries = Object.entries(tiers);

logger?.("Collected tier entries:", JSON.stringify(tierEntries, null, 4));

Expand Down
Loading