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

Add banner opencollective.com/$slug/financial-contributors.svg #502

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mkurz
Copy link

@mkurz mkurz commented Nov 28, 2021

Following this route entry:

app.get('/:collectiveSlug/:backerType.svg', controllers.banner);

the controller method will render users by fetching them from the api:
users = await fetchMembersWithCache(req.params);

In the fetchMembers method the backerType param will be handled if its value is contributors:
if (backerType === 'contributors') {

or if its value is sponsor[s], organization[s] or individual[s] and backer[s] (which the else branch does not check for these two values, so I guess there is some other routing/proxy going on before opencollective-images processes the url?)
} else if (backerType) {
if (backerType.match(/sponsor/i) || backerType.match(/organization/i)) {
type = 'ORGANIZATION,COLLECTIVE';
} else {
type = 'USER';
}

Now that allows us to build following urls:

These 4 generate the same svg:

These 4 generate the same svg:

Finally a svg for contributors:

Now with this pull request we would also have:

which would display all financial contributors, bascially a sum of the above individuals + organizations.

This is bascially the same concept you use in the badge when you render
https://opencollective.com/playframework/all/badge.svg
which renders:

Looking at the badge.js source:

if (req.params.backerType.match(/sponsor/i) || req.params.backerType.match(/organization/i)) {
backerType = 'sponsors';
label = req.query.label || req.params.backerType;
} else if (req.params.backerType.match(/backer/i) || req.params.backerType.match(/individual/i)) {
backerType = 'backers';
label = req.query.label || req.params.backerType;
} else {
backerType = 'all';
label = req.query.label || 'financial contributors';
}

where you label all backers as financial contributors by default.
And even more important that's what you do in the graphql query as well, you just fetch "all" "backers" and define them as "financial contributors" in the last else here:
if (backerType.match(/sponsor/i) || backerType.match(/organization/i)) {
count = res.Collective.stats.backers.organizations;
name = backerType;
} else if (backerType.match(/backer/i) || backerType.match(/individual/i)) {
count = res.Collective.stats.backers.users;
name = backerType;
} else {
count = res.Collective.stats.backers.all;
name = 'financial contributors';
}

So that's what I do in the pull request as well to render financial-contributor.svg:
I just pass null as type, to fetch all organizations, users, etc. and the role = 'BACKER'; line makes sure they are all backers.

What do you think?
I think it makes sense 😉

@mkurz
Copy link
Author

mkurz commented Dec 17, 2021

@znarf What do you think?

@smileBeda
Copy link

This is still stalling? It would be super useful and fair to show all contributors, not separately, but together!

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.

2 participants