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

--exportAttributes labels #28

Open
dev0zzz opened this issue Aug 27, 2020 · 3 comments
Open

--exportAttributes labels #28

dev0zzz opened this issue Aug 27, 2020 · 3 comments

Comments

@dev0zzz
Copy link

dev0zzz commented Aug 27, 2020

When I write the command

githubCsvTools --exportAttributes state,created_at,labels,milestone.title,milestone.created_at,milestone.due_on,number,title,body

I get all the label attributes, I just want to have the labels.name

but if I type labels.name i get nothing

@gavinr gavinr added the bug label Aug 27, 2020
@gavinr
Copy link
Owner

gavinr commented Aug 27, 2020

Thanks for the report. Looks like a bug - right now the code handles the single-object items (user, assignee, milestone, closed_by), but we'll have to update it to handle the arrays (labels, assignees). PRs welcome!

@94rain
Copy link

94rain commented Mar 3, 2022

It seems that the logics are already implemented in defaultExportColumns method, but not in specificAttributeColumns

github-csv-tools/export.js

Lines 108 to 130 in 475a58f

if (issueObject.user) {
ret.user = issueObject.user.login;
}
if (issueObject.labels) {
ret.labels = issueObject.labels
.map((labelObject) => {
return labelObject.name;
})
.join(",");
}
if (issueObject.assignee && issueObject.assignee.login) {
ret.assignee = issueObject.assignee.login;
}
if (issueObject.assignees && issueObject.assignees.length > 0) {
ret.assignees = issueObject.assignees
.map((assigneeObject) => {
return assigneeObject.login;
})
.join(",");
}
if (issueObject.milestone && issueObject.milestone.title) {
ret.milestone = issueObject.milestone.title;
}

As a temporary workaround, a simple change to specificAttributeColumns can resolve the labels issue. (Adding the if-clause)

const specificAttributeColumns = (data, attributes) => {
  return data.map((issueObject) => {
    const ret = {};
    attributes.forEach((attribute) => {
      ret[attribute] = getDataAttribute(issueObject, attribute);
      if (attribute === "labels") {
        ret[attribute] = issueObject.labels
        .map((labelObject) => {
          return labelObject.name;
        })
        .join(",");
      }
    });
    return ret;
  });
};

But this could be a bit redundant. Maybe we can decompose export.js#L108-L130 to a single method that is invoked by both defaultExportColumns and specificAttributeColumns?

@kalanchan
Copy link

is this still being worked on? I get blanks when trying to export labels.name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants