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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Chocrates
Copy link

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
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?

@@ -159,6 +161,9 @@ def get_per_issue_metrics(
)
elif issue.state == "open": # type: ignore
num_issues_open += 1
if env_vars.hide_created_at is False:
issue_with_metrics.created_at = issue.created_at

Copy link
Member

@jmeridth jmeridth Jan 22, 2025

Choose a reason for hiding this comment

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

Suggested change
if not env_vars.hide_created_at:
issue_with_metrics.created_at = issue["createdAt"]

we don't need the above in both the if and else. it can go once here. wdyt?

The issue["createdAt"] also fixes your mypy linting issue.

@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

@@ -37,6 +37,7 @@ def __init__(
time_in_draft=None,
labels_metrics=None,
mentor_activity=None,
created_at=None,
Copy link
Member

Choose a reason for hiding this comment

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

please update the docs above

@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.

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