@@ -360,7 +360,12 @@ def update_repo_time_slider(repo_name):
360360 end_date : datetime .date = datetime .date (end_time .year , end_time .month , end_time .day )
361361 # This will create a list from 0 to x, where x is the number of months
362362 # the end timestamp is after the beginning:
363- months : list = list (range (0 , month_diff (start_date , end_date )))
363+ if month_diff (start_date , end_date ) < 1 :
364+ # Handle situation when the repository has less than a month of activity
365+ months : list = list (range (0 , 2 ))
366+ else :
367+ months : list = list (range (0 , month_diff (start_date , end_date )))
368+
364369 slider_min : int = months [0 ]
365370 slider_max : int = months [- 1 ] # I.e. the last item in `months`
366371
@@ -461,27 +466,22 @@ def draw_commits_plot(repo_name, slider_values):
461466 # `freq="1M"` groups `committed` timestamps by month:
462467 # https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases
463468 # https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Grouper.html
464- repo_commits_monthly = repo_commits .drop_duplicates (
469+ repo_commits_monthly = repo_commits [
470+ (repo_commits ["committed" ] >= start_time ) & (repo_commits ["committed" ] <= end_time )
471+ ].drop_duplicates (
465472 subset = "committed"
466473 ).groupby (
467474 pandas .Grouper (key = "committed" , freq = "1M" )
468475 ).count ()
469476
470- commits_fig = plotly .express .bar (
471- repo_commits_monthly ,
477+ commits_fig = plotly .graph_objects .Figure ()
478+ commits_fig .add_trace (plotly .graph_objects .Bar (
479+ name = "Commits bar plot" ,
472480 x = repo_commits_monthly .index ,
473- y = repo_commits_monthly ["hash" ],
474- range_x = [str (start_date ), str (end_date )]
475- )
476-
477- # commits_fig = plotly.graph_objects.Figure()
478- # commits_fig.add_trace(plotly.graph_objects.Bar(
479- # name="Commits bar plot",
480- # x=repo_commits_monthly.index,
481- # y=repo_commits_monthly["hash"],
482- # xperiod="M1",
483- # xperiodalignment="middle"
484- # ))
481+ y = repo_commits_monthly ["hash" ],
482+ xperiod = "M1" ,
483+ xperiodalignment = "middle"
484+ ))
485485 commits_fig .update_layout (
486486 xaxis_title = "Date" ,
487487 yaxis_title = "Number of commits"
0 commit comments