The Open Sauced project leverages a user's open-sauced-goals repo as a data store. At some point before I started contributing, the project began using more than the issues list to store data. In working toward a richer data set (I assume), the project began leveraging a file called data.json
to store additional information about repos that the user intends to contribute to, such as stargazers_count
, open_issues_count
, and forks_count
.
This file is updated using GitHub actions every few days, and also as triggered when someone adds or removes goals (creates an issue or closes an issue).
The way this data interweaves with the issues list has some edge cases that I had been becoming more familiar with and my attention was drawn to the use of the lodash library's merge function in blending the data from the issues list and from the data.json
file.
To see how this worked, you can go to https://codepen.io/travist/full/jrBjBz/ and put this in the code input and click "Execute":
var issues = [
{title:"actions/typescript-action",description:"want to make some sweet actions",issue_number:1},
{title:"nickytonline/epic-actions",description:"want to make some sweet actions",issue_number:2},
// {title:"open-sauced/actions",description:"help with the monorepo management",issue_number:3}
];
var otherData = [
{full_name:"actions/typescript-action","stargazers_count":873,"open_issues_count":13,"forks_count":208},
{full_name:"nickytonline/epic-actions","stargazers_count":3,"open_issues_count":2,"forks_count":0},
{full_name:"open-sauced/actions","stargazers_count":3,"open_issues_count":2,"forks_count":1}
];
result = _.merge(issues,otherData);
The commented line shows the theoretical effect of "removing" a goal (= marking the issue as closed in the open-sauced-goals repo). The problem with what you see is that the issues list should be the single source of truth and the information coming from data.json
should be supplemental for display purposes. As this was, the 3rd item would be missing the "issue_number", so it shouldn't really be in the list. In the brief period of time after removing a goal, when the data.json
was not up to date and the user interface was still up, the merge
function would not serve us well here.
I tried to replace this function with something more appropriate and I happened to notice that this one and the sortBy
function were the only parts of the codebase where we used the lodash
library directly. I took the opportunity to replace both and drop this library from our direct dependencies, and that's what I was doing in https://github.com/open-sauced/open-sauced/pull/1156
Stay tuned later this week for another edge case that I got to work with GitHub actions some, and learn a little bit about managing multiple repos!
Top comments (0)