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

fix: Fix timestamp handling (elapsed; formatting) #111

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Change Log
Unreleased
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[1.8.1] - 2024-07-11
~~~~~~~~~~~~~~~~~~~~

* Fix elapsed-time calculations to always use UTC. Other clocks can be altered partway through by Django config settings being loaded while the timer is running, resulting in reporting elapsed time of "-17999.895582 seconds" or similar.
* Fix report filename to use year-month-day order, not year-day-month. (Also more compact, now.)

[1.8.0] - 2024-03-31
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion code_annotations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Extensible tools for parsing annotations in codebases.
"""

__version__ = '1.8.0'
__version__ = '1.8.1'
4 changes: 2 additions & 2 deletions code_annotations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,9 @@ def report(self, all_results, report_prefix=''):
"""
self.echo.echo_vv(yaml.dump(all_results, default_flow_style=False))

now = datetime.datetime.now()
now = datetime.datetime.utcnow()
report_filename = os.path.join(self.config.report_path, '{}{}.yaml'.format(
report_prefix, now.strftime('%Y-%d-%m-%H-%M-%S')
report_prefix, now.strftime('%Y%m%d-%H%M%S')
))

formatted_results = self._format_results_for_report(all_results)
Expand Down
12 changes: 6 additions & 6 deletions code_annotations/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def django_find_annotations(
Subcommand for dealing with annotations in Django models.
"""
try:
start_time = datetime.datetime.now()
start_time = datetime.datetime.utcnow()
config = AnnotationConfig(config_file, report_path, verbosity)
searcher = DjangoSearch(config)

Expand Down Expand Up @@ -106,7 +106,7 @@ def django_find_annotations(
for filename in annotated_models:
annotation_count += len(annotated_models[filename])

elapsed = datetime.datetime.now() - start_time
elapsed = datetime.datetime.utcnow() - start_time
click.echo("Search found {} annotations in {} seconds.".format(
annotation_count, elapsed.total_seconds()
))
Expand Down Expand Up @@ -137,7 +137,7 @@ def static_find_annotations(config_file, source_path, report_path, verbosity, li
Subcommand to find annotations via static file analysis.
"""
try:
start_time = datetime.datetime.now()
start_time = datetime.datetime.utcnow()
config = AnnotationConfig(config_file, report_path, verbosity, source_path)
searcher = StaticSearch(config)
all_results = searcher.search()
Expand All @@ -161,7 +161,7 @@ def static_find_annotations(config_file, source_path, report_path, verbosity, li
report_filename = searcher.report(all_results)
click.echo(f"Report written to {report_filename}.")

elapsed = datetime.datetime.now() - start_time
elapsed = datetime.datetime.utcnow() - start_time
annotation_count = 0

for filename in all_results:
Expand Down Expand Up @@ -191,7 +191,7 @@ def generate_docs(
"""
Generate documentation from a code annotations report.
"""
start_time = datetime.datetime.now()
start_time = datetime.datetime.utcnow()

try:
config = AnnotationConfig(config_file, verbosity)
Expand All @@ -210,7 +210,7 @@ def generate_docs(
renderer = ReportRenderer(config, report_files)
renderer.render()

elapsed = datetime.datetime.now() - start_time
elapsed = datetime.datetime.utcnow() - start_time
click.echo(f"Report rendered in {elapsed.total_seconds()} seconds.")
except Exception as exc:
click.echo(traceback.print_exc())
Expand Down
2 changes: 1 addition & 1 deletion code_annotations/generate_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, config, report_files):
self.config = config
self.echo = self.config.echo
self.report_files = report_files
self.create_time = datetime.datetime.now().isoformat()
self.create_time = datetime.datetime.utcnow().isoformat()

self.full_report = self._aggregate_reports()

Expand Down
Loading