Skip to content

Commit 9055581

Browse files
authored
Add the date to the downloads summary sheet (#39)
1 parent e0f0c30 commit 9055581

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

pymetrics/summarize.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,13 @@
77
from packaging.version import Version, parse
88

99
from pymetrics.output import append_row, create_spreadsheet, get_path, load_csv
10-
from pymetrics.time_utils import get_current_year, get_min_max_dt_in_year
10+
from pymetrics.time_utils import get_current_year, get_dt_now_spelled_out, get_min_max_dt_in_year
1111

1212
TOTAL_COLUMN_NAME = 'Total Since Beginning'
1313
ECOSYSTEM_COLUMN_NAME = 'Ecosystem'
1414
BREAKDOWN_COLUMN_NAME = 'Library'
1515
BSL_COLUMN_NAME = 'Type'
16-
SHEET_NAMES = [
17-
'all',
18-
'vendor-mapping',
19-
'SDV',
20-
'PreBSL-vs-BSL',
21-
]
16+
SHEET_NAMES = ['all', 'vendor-mapping', 'SDV', 'PreBSL-vs-BSL', 'metainfo']
2217
OUTPUT_FILENAME = 'Downloads_Summary'
2318
pre_bsl_versions = {
2419
'rdt': '1.2.1',
@@ -343,11 +338,18 @@ def summarize_downloads(
343338
)
344339
bsl_vs_pre_bsl_df = append_row(bsl_vs_pre_bsl_df, version_row)
345340
vendor_df = vendor_df.rename(columns={vendor_df.columns[0]: ECOSYSTEM_COLUMN_NAME})
341+
342+
runtime_data = {
343+
'index': ['date'],
344+
'value': [get_dt_now_spelled_out()],
345+
}
346+
metainfo_df = pd.DataFrame(runtime_data)
346347
sheets = {
347348
SHEET_NAMES[0]: all_df,
348349
SHEET_NAMES[1]: vendor_df,
349350
SHEET_NAMES[2]: breakdown_df,
350351
SHEET_NAMES[3]: bsl_vs_pre_bsl_df,
352+
SHEET_NAMES[4]: metainfo_df,
351353
}
352354
if verbose:
353355
for sheet_name, df in sheets.items():

pymetrics/time_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,13 @@ def _create_unique_name(name, list_names):
7272
result += '_'
7373

7474
return result
75+
76+
77+
def format_datetime_as_date(dt: datetime):
78+
"""Format datetime as spelled out date (Month Day, Year)."""
79+
return dt.strftime('%B %-d, %Y')
80+
81+
82+
def get_dt_now_spelled_out(tz=None):
83+
"""Get the current date as full spelled out string."""
84+
return format_datetime_as_date(datetime.now(tz=tz))

0 commit comments

Comments
 (0)