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

feat: Adding 'Created_At' column, defaulting to false #460

Merged
merged 4 commits into from
Jan 26, 2025

Conversation

Chocrates
Copy link
Contributor

Pull Request

Proposed Changes

We use this internally to pull metrics on open PR's and they would like to see the creation timestamp.

This PR adds the created_at column, defaulting to false with the HIDE_CREATED_AT environment variable.

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request
  • run make lint and fix any issues that you have introduced
  • run make test and ensure you have test coverage for the lines you are introducing
  • If publishing new data to the public (scorecards, security scan results, code quality results, live dashboards, etc.), please request review from @jeffrey-luszcz

Reviewer

  • Label as either fix, documentation, enhancement, infrastructure, maintenance, or breaking

@Chocrates Chocrates requested a review from a team as a code owner January 21, 2025 22:12
@Chocrates
Copy link
Contributor Author

make lint gave me these two errors. I am unsure how to fix them, if you could help point me in the right direction.

mypy --config-file=.github/linters/.mypy.ini *.py
issue_metrics.py:112: error: Item "dict[Any, Any]" of "dict[Any, Any] | Any" has no attribute "created_at"  [union-attr]
issue_metrics.py:165: error: Item "dict[Any, Any]" of "dict[Any, Any] | Any" has no attribute "created_at"  [union-attr]
Found 2 errors in 1 file (checked 34 source files)

Copy link
Member

@jmeridth jmeridth left a comment

Choose a reason for hiding this comment

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

One code suggested to minimize duplication. Can you please add negative tests to test_config.py and tests to test_markdown_writer.py and test_json_writer.py?

@jmeridth
Copy link
Member

jmeridth commented Jan 22, 2025

make lint gave me these two errors. I am unsure how to fix them, if you could help point me in the right direction.

mypy --config-file=.github/linters/.mypy.ini *.py
issue_metrics.py:112: error: Item "dict[Any, Any]" of "dict[Any, Any] | Any" has no attribute "created_at"  [union-attr]
issue_metrics.py:165: error: Item "dict[Any, Any]" of "dict[Any, Any] | Any" has no attribute "created_at"  [union-attr]
Found 2 errors in 1 file (checked 34 source files)

Pulling your branch and looking into this.

UPDATE: Fix below

@jmeridth
Copy link
Member

jmeridth commented Jan 22, 2025

make lint gave me these two errors. I am unsure how to fix them, if you could help point me in the right direction.

mypy --config-file=.github/linters/.mypy.ini *.py
issue_metrics.py:112: error: Item "dict[Any, Any]" of "dict[Any, Any] | Any" has no attribute "created_at"  [union-attr]
issue_metrics.py:165: error: Item "dict[Any, Any]" of "dict[Any, Any] | Any" has no attribute "created_at"  [union-attr]
Found 2 errors in 1 file (checked 34 source files)

The code suggestion fixes the linting issue. Since issue is a dict, you have to access the attribute with the key createdAt.

issue_with_metrics.created_at = issue["createdAt"]
(.venv) ➜  issue-metrics git:(create_at) mypy --config-file=.github/linters/.mypy.ini *.py
Success: no issues found in 34 source files

@jmeridth
Copy link
Member

@Chocrates thank you for your contribution. Hopefully my comments above help you get past the linting issue and if you can look at the other suggestions. Cheers.

Chocrates and others added 3 commits January 25, 2025 08:59
Co-authored-by: JM (Jason Meridth) <[email protected]>
Signed-off-by: Chris McIntosh <[email protected]>
- [x] bad indenting
- [x] bad code still present
- [x] docs
- [x] bad f string, single vs double quotes also
- [x] line too long, ignoring

Signed-off-by: jmeridth <[email protected]>
@jmeridth jmeridth merged commit cbd995c into github:main Jan 26, 2025
6 checks passed
@Chocrates
Copy link
Contributor Author

Thanks @jmeridth, sorry I didnt get back to it in time

@jmeridth
Copy link
Member

Thanks @jmeridth, sorry I didnt get back to it in time

No worries. My suggestion didn't include the deletes. My bad. Figured I could get it over the finish line. Thank you for the addition. We know others will use it. Cheers.

@Chocrates
Copy link
Contributor Author

We need to revert this @jmeridth, getting an error not being able to find CreatedAt.

It is on my work account so i don't have the log available right now, but it is this line https://github.com/github/issue-metrics/pull/460/files#diff-ce3c5ee2a2d613519aa58370092bb57e6cf099d988893cad9c5aec0cf10776e8R163

I don't recall what i had before issue.created_at i think, but i believe that worked for some reason https://github.com/github/issue-metrics/pull/460/files#diff-ce3c5ee2a2d613519aa58370092bb57e6cf099d988893cad9c5aec0cf10776e8R163

@jmeridth
Copy link
Member

We need to revert this @jmeridth, getting an error not being able to find CreatedAt.

It is on my work account so i don't have the log available right now, but it is this line https://github.com/github/issue-metrics/pull/460/files#diff-ce3c5ee2a2d613519aa58370092bb57e6cf099d988893cad9c5aec0cf10776e8R163

I don't recall what i had before issue.created_at i think, but i believe that worked for some reason https://github.com/github/issue-metrics/pull/460/files#diff-ce3c5ee2a2d613519aa58370092bb57e6cf099d988893cad9c5aec0cf10776e8R163

I think it needs to be created_at. Will push that change.

@jmeridth
Copy link
Member

@Chocrates I just merged #462 and released v3.18.0. Please try that. If that still fails, I'll revert both PRs.

@Chocrates
Copy link
Contributor Author

No luck, I think it needed to be issue.created_at

Error was "Type error: issuesearchresult object is not subscriptable"

@jmeridth
Copy link
Member

jmeridth commented Jan 27, 2025

No luck, I think it needed to be issue.created_at

Error was "Type error: issuesearchresult object is not subscriptable"

I changed createdAt to created_at here. You're still getting an errors with v3.18.0 (latest)? where do you think it needs to be issue.created_at exactly?

@Chocrates
Copy link
Contributor Author

Hey @jmeridth, like this commit.

Basically we can't access it like an array for somereason

issue.created_at vs issue["created_at"]

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

Successfully merging this pull request may close these issues.

2 participants