Skip to content

Commit

Permalink
Avoid querying a duplicated result (resolve #59)
Browse files Browse the repository at this point in the history
  • Loading branch information
payne911 committed Mar 22, 2023
1 parent 86d555a commit 229d0ce
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions website/src/queries-logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ function update_table_trying_use_filter() {
}
}

function is_duplicate_repo(name) {
for (const fork of TABLE_DATA) {
if (fork['name'] === name)
return true;
}
return false;
}

/** Updates table data, then calls function to update the table. */
function update_table_data(responseData, user, repo, parentDefaultBranch) {
if (isEmpty(responseData)) {
Expand All @@ -209,6 +217,9 @@ function update_table_data(responseData, user, repo, parentDefaultBranch) {
if (RATE_LIMIT_EXCEEDED) // we can skip everything below because they are only requests
continue;

if (is_duplicate_repo(currFork.full_name))
continue; // abort because repo is already listed

let datum = {
'name': currFork.full_name,
'stars': currFork.stargazers_count,
Expand Down

1 comment on commit 229d0ce

@pepa65
Copy link

@pepa65 pepa65 commented on 229d0ce Mar 25, 2023

Choose a reason for hiding this comment

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

Maybe put the block of

if (is_duplicate_repo(currFork.full_name))
      continue; // abort because repo is already listed

Above the check for RATE_LIMIT_EXCEEDED (because it's a skip anyway).

Is line 99 more effective with == instead of ===?

I don't know, this code looks right in principle. Can you log how many entries get skipped by is_duplicate_repo?

Please sign in to comment.