Skip to content

Commit 9d5db5a

Browse files
authored
Add the date to the GitHub Summary sheet (#36)
1 parent 7c9f40a commit 9d5db5a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

gitmetrics/summarize.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from gitmetrics.constants import ECOSYSTEM_COLUMN_NAME
99
from gitmetrics.output import create_spreadsheet, load_spreadsheet
10-
from gitmetrics.time_utils import get_current_year, get_min_max_dt_in_year
10+
from gitmetrics.time_utils import get_current_year, get_dt_now_spelled_out, get_min_max_dt_in_year
1111

1212
dir_path = os.path.dirname(os.path.realpath(__file__))
1313

@@ -16,7 +16,7 @@
1616

1717
TOTAL_COLUMN_NAME = 'Total Since Beginning'
1818
OUTPUT_FILENAME = 'GitHub_Summary'
19-
SHEET_NAMES = ['Unique users', 'User issues', 'vendor-mapping']
19+
SHEET_NAMES = ['Unique users', 'User issues', 'vendor-mapping', 'metainfo']
2020
START_YEAR = 2021
2121

2222

@@ -103,10 +103,16 @@ def summarize_metrics(
103103
users_issues_df = append_row(users_issues_df, issues_row)
104104

105105
vendor_df = vendor_df.rename(columns={vendor_df.columns[0]: ECOSYSTEM_COLUMN_NAME})
106+
runtime_data = {
107+
'index': ['date'],
108+
'value': [get_dt_now_spelled_out()],
109+
}
110+
metainfo_df = pd.DataFrame(runtime_data)
106111
sheets = {
107112
SHEET_NAMES[0]: unique_users_df,
108113
SHEET_NAMES[1]: users_issues_df,
109114
SHEET_NAMES[2]: vendor_df,
115+
SHEET_NAMES[3]: metainfo_df,
110116
}
111117
if verbose:
112118
for sheet_name, df in sheets.items():

gitmetrics/time_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ def get_min_max_dt_in_year(year):
2525
min_datetime = get_first_datetime_in_year(year)
2626
max_datetime = get_last_datetime_in_year(year)
2727
return min_datetime, max_datetime
28+
29+
30+
def format_datetime_as_date(dt: datetime):
31+
"""Format datetime as spelled out date (Month Day, Year)."""
32+
return dt.strftime('%B %-d, %Y')
33+
34+
35+
def get_dt_now_spelled_out(tz=None):
36+
"""Get the current date as full spelled out string."""
37+
return format_datetime_as_date(datetime.now(tz=tz))

0 commit comments

Comments
 (0)