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

added check function for maximum page count of issue list #855

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Changes from 1 commit
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
27 changes: 24 additions & 3 deletions reviews/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ <h2 class="notoc">Filter results</h2>
var totals=0
var counter=maxpages

function getAllData () {
for (var p=1;p<maxpages+1;p++) fetchIssues(p)
function getAllData (maxpages_new) {
for (var p=1;p<maxpages_new+1;p++) fetchIssues(p)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a better name? Perhaps pages? Or totalPages? Why don't we just replace the value of maxpages with a call to fetchIssuesCount()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hrm.. since this PR was something of quick hack, so to remove old variable, I think I should rewrite this part with Promise.all.
Please wait a bit more for rewriting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ping

var timer = setInterval(function() {
if (counter === 0) {
clearInterval(timer)
Expand Down Expand Up @@ -162,6 +162,24 @@ <h2 class="notoc">Filter results</h2>
}
request.send();
}

function fetchIssuesCount() {
var req = new Request('https://api.github.com/repos/w3c/i18n-activity/issues?per_page=100&page=1', { method: "HEAD" });
fetch(req)
.then((response) => {
var last = 1;
if (response.headers.has('Link')) {
var links = response.headers.get('Link');
links.split(',').forEach(link => {
var link_val = link.match(/<.*page=([0-9]+)>; rel="(.*)"/);
if ((link_val) && (link_val[2] == 'last')) {
last = link_val[1];
}
});
}
getAllData(parseInt(last, 10));
});
}


function checkDates () {
Expand Down Expand Up @@ -415,7 +433,10 @@ <h2 class="notoc">Filter results</h2>
document.getElementById('total').textContent = "There are "+filteredIssues+" issues."
}
</script>
<script>window.onload = getAllData()</script>
<script>
// window.onload = getAllData()
Copy link
Contributor

Choose a reason for hiding this comment

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

remove dead code (it's why we have version control)

window.onload = fetchIssuesCount();
</script>

<footer id="thefooter"></footer>
<script type="text/javascript">document.getElementById('thefooter').innerHTML = g.bottomOfPage</script>
Expand Down