-
Notifications
You must be signed in to change notification settings - Fork 193
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
[tutorial] Explanation of code in webcompat.com #1640
Comments
sets vs set/frozenset in views.pyUsually better to use a reference with a commit view so it doesn't get lost in the future. webcompat.com/webcompat/views.py Line 179 in eb8b2ac
https://docs.python.org/2/library/sets.html
The module |
namedtuple in config for labelswebcompat.com/config/__init__.py Lines 46 to 62 in c613a78
Yes just to be more descriptive and easier to manipulate. We use them in templates. I did that initially to help the passing of arguments to @magsout This code will change soon when we switch to milestones (Issue #886 ) On GitHub, Blame is a good tool to find out the reason behind a change. Though in this specific case it doesn't help that much because we moved the config to a new file and it destroyed the history. I wish there was a way to link history across file moves (but that's another topic.) So Let's see, we can probably search in the commits and issues. We had a discussion about this in the past @miketaylr was not very fond of it. He found it confusing. We could switch to something else. As I said this code will change anyway very soon. I'm happy to kill them with fire if it confuses more people. 🔥 |
Homepage list of issues
The issues are populated into the section <div id="js-lastIssue">
<script type="text/template" id="needstriage-tmpl">
<% if (issues.length) { %>
<% _.each(issues, function(issue) { %>
<article class="wc-IssueList wc-IssueList--<%= issue.stateClass %> wc-IssueList--large js-IssueList">
<div class="wc-IssueList-section">
<header class="wc-IssueList-header">
<a class="wc-Link" href="/issues/<%= issue.number %>">
<span class="wc-IssueList-count">Issue <%= issue.number %></span>: <%- issue.title %>
</a>
</header>
<p>
<span class="wc-IssueList-metadata">Opened: <time><%= issue.createdAt %></time></span>
<span class="wc-IssueList-metadata">Comments: <%= issue.commentNumber %></span>
</p>
</div>
<div class="wc-IssueList-section">
<span class="wc-IssueList-label js-Issue-label">
<% _.each(issue.labels, function(label) { %>
<a href="/issues?q=label:<%= label.remoteName %>"
class="wc-Labels" data-remotename="<%= label.remoteName %>"
title="Labels : <%= label.name %>"><%= label.name %></a>
<% }); %></span>
</div>
</article>
<% }); %>
<% } else { %>
<p>Nothing here currently, cool!</p>
<% } %>
</script>
</div> The HTTP request is made by the JavaScript as an XHR request asking for: Which means we hit this route in the code: webcompat.com/webcompat/api/endpoints.py Lines 107 to 145 in eb8b2ac
which ends up doing: webcompat.com/webcompat/api/endpoints.py Line 132 in eb8b2ac
return api_request('get', issues_path, params=params) aka webcompat.com/webcompat/helpers.py Lines 450 to 471 in eb8b2ac
Two cases at this moment, depending if you are logged in or not. Little tip here. If you do not remember what are the methods you can call on a function, you can use print(dir(function_name)) it will display all the method associated to a specific name. so for example if you do that on
So let's print
So this is the URL request that is sent to GitHub. GitHub will reply to webcompat.com which in return will send it back to the user. Basically webcompat.com proxy all requests to GitHub. |
About reviews
Yes. Perfectly fine. :) |
@karlcow thanks for your time and answers. the app flow is particularly helpful.
is that the same as meaning the FE makes a request (like issues) to the BE api which makes a corresponding request to Github's api? |
@cch5ng what are FE and BE? |
@karlcow FE = Front end, BE = Back end |
ok let me try to make a graph of what is happening? So it becomes clearer. The separation is not totally Front-end / Back-end. Or more exactly it's usually better to talk in terms of Request/Response because, when you "proxy", a server is at the same time front-end and back end. |
It is something which looks a bit like this:
|
Would it be possible to move that to / reference that in our wiki as issues are not meant for documentation purpose? That would be great. Thanks! |
@cch5ng started to ask question about the code. I will use this space to reply to the questions which might be useful for others.
Extract from #1628 (comment)
The text was updated successfully, but these errors were encountered: