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

Implements a svg badge.. #1546

Merged
merged 5 commits into from
Jun 28, 2018
Merged

Implements a svg badge.. #1546

merged 5 commits into from
Jun 28, 2018

Conversation

pinkiebell
Copy link
Contributor

.."Open bounties " for the /funding/embed endpoint.

<BASE_URL>/funding/embed/?repo=https://github.com/gitcoinco/web&badge=1

Fixes: #1378

.."Open bounties <n open bounties>" for the /funding/embed endpoint.

<BASE_URL>/funding/embed/?repo=https://github.com/gitcoinco/web&badge=1

Fixes: #1378
@@ -8,7 +8,22 @@
from ratelimit.decorators import ratelimit

AVATAR_BASE = 'assets/other/avatars/'

SVG_BADGE =\
"""\

Choose a reason for hiding this comment

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

E122 continuation line missing indentation or outdented

@@ -101,6 +116,18 @@ def embed(request):
return err_response

try:
badge = request.GET.get('badge', False)
if badge:
open_bounties = Bounty.objects.current() \

Choose a reason for hiding this comment

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

E111 indentation is not a multiple of four

idx_status__in=['open']
)

return HttpResponse(SVG_BADGE.replace('N_BOUNTIES', str(len(open_bounties))),

Choose a reason for hiding this comment

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

E111 indentation is not a multiple of four

)

return HttpResponse(SVG_BADGE.replace('N_BOUNTIES', str(len(open_bounties))),
content_type='image/svg+xml');

Choose a reason for hiding this comment

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

E703 statement ends with a semicolon

@codecov
Copy link

codecov bot commented Jun 26, 2018

Codecov Report

Merging #1546 into master will increase coverage by 0.15%.
The diff coverage is 16.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1546      +/-   ##
==========================================
+ Coverage   28.25%   28.41%   +0.15%     
==========================================
  Files         129      130       +1     
  Lines        9531     9576      +45     
  Branches     1235     1240       +5     
==========================================
+ Hits         2693     2721      +28     
- Misses       6740     6757      +17     
  Partials       98       98
Impacted Files Coverage Δ
app/dashboard/embed.py 7.69% <16.66%> (+0.33%) ⬆️
app/dashboard/views.py 14.71% <0%> (-0.12%) ⬇️
app/avatar/admin.py 78.57% <0%> (ø)
app/dashboard/models.py 56.25% <0%> (+0.08%) ⬆️
app/avatar/models.py 43.58% <0%> (+1.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b92a5c6...122af7d. Read the comment docs.

pinkiebell added 2 commits June 26, 2018 13:15
Refactor the svg markup.
Copy link
Contributor

@mbeacom mbeacom left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

Can we update this single string SVG_BADGE to use the Django template engine?

You can define the svg in a .txt file under dashboard/templates and update N_BOUNTIES to {{ bounties_count }} - Then you'd call tmpl = loader.get_template('template/path.txt') and tmpl.render({'bounties_count': open_bounties.count()})

Feel free to reach out on Slack or in this PR if you have any questions!

)

return HttpResponse(
SVG_BADGE.replace('N_BOUNTIES', str(len(open_bounties))),
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll want to update this to use .count() versus len() to avoid performance issues.

@mbeacom
Copy link
Contributor

mbeacom commented Jun 27, 2018

Preview of badge provided by @pinkiebell

Shield

pinkiebell added 2 commits June 27, 2018 23:03
Use the template engine to render the svg markup.
Make isort happy ;)
Copy link
Member

@thelostone-mc thelostone-mc left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@mbeacom mbeacom left a comment

Choose a reason for hiding this comment

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

@pinkiebell Thanks for turning around my comments - LGTM! :shipit: 🚢

Welcome to the community!

@mbeacom mbeacom merged commit 8173c32 into gitcoinco:master Jun 28, 2018
@pinkiebell pinkiebell deleted the bounty branch October 30, 2018 08:27
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