forked from open-sauced/open-sauced
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: limit stars list to only the last 3 unused stars (open-sauced#1124
- Loading branch information
Showing
7 changed files
with
67 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// remove duplicates from data based on existing stars | ||
function filterForUniqueStars(data, stars) { | ||
return stars.filter((repo) => { | ||
return data.find((repoData) => repoData.full_name === repo.full_name) === undefined; | ||
}); | ||
} | ||
|
||
// only return starts not represent in the data.json | ||
function remainingStars(data, stars) { | ||
try { | ||
const remainingStars = filterForUniqueStars(data, stars); | ||
return [...remainingStars.slice(0, 3)] || []; | ||
} catch { | ||
console.log("You have no stars stored in your open-sauced-goals repo. Check to see if the Open Sauced integration is up to date."); | ||
return []; | ||
} | ||
} | ||
|
||
export {remainingStars}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {remainingStars} from "./manageStarData"; | ||
|
||
const testData = [ | ||
{full_name: "graphql/graphiql", stargazers_count: 12529, open_issues_count: 181, forks_count: 1338}, | ||
{full_name: "11ty/eleventy", stargazers_count: 9894, open_issues_count: 441, forks_count: 281}, | ||
]; | ||
const testStars = [ | ||
{full_name: "graphql/graphiql", stargazers_count: 12529, open_issues_count: 181, forks_count: 1338}, | ||
{full_name: "open-sauced/open-sauced", stargazers_count: 12529, open_issues_count: 181, forks_count: 1338}, | ||
{full_name: "11ty/eleventy", stargazers_count: 9894, open_issues_count: 441, forks_count: 281}, | ||
]; | ||
|
||
// test cases for the remainingStars function | ||
describe("remainingStars", () => { | ||
test("should return the only one of remaining stars", async() => { | ||
expect(remainingStars(testData, testStars).length).toBe(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters