lunarflu HF staff commited on
Commit
afa3853
1 Parent(s): 1d7ce74

total contrib across year

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -737,7 +737,6 @@ def parse_activity_dates(activity_data):
737
 
738
  def create_plot(username, year):
739
  dates_in_year = get_dates_in_year(year)
740
-
741
  dates_in_year = [d.date() for d in dates_in_year]
742
 
743
  activity_data = get_user_likes(username)
@@ -748,6 +747,8 @@ def create_plot(username, year):
748
  if date in activity_count:
749
  activity_count[date] += 1
750
 
 
 
751
  # activity->color
752
  def get_color(activity_count):
753
  if activity_count == 0:
@@ -762,7 +763,7 @@ def create_plot(username, year):
762
  # data->Plotly
763
  num_weeks = len(dates_in_year) // 7 + (1 if len(dates_in_year) % 7 != 0 else 0)
764
 
765
- z = [[None for _ in range(num_weeks)] for _ in range(7)]
766
  hover_texts = [["" for _ in range(num_weeks)] for _ in range(7)]
767
 
768
  for idx, date in enumerate(dates_in_year):
@@ -799,9 +800,9 @@ def create_plot(username, year):
799
  ))
800
 
801
  # lock the plot size and ensure cells are square
802
- cell_size = 20
803
  fig.update_layout(
804
- title=f'{username} Activity in {year}',
805
  xaxis_nticks=52,
806
  yaxis_nticks=7,
807
  xaxis_title=' ',
@@ -814,7 +815,6 @@ def create_plot(username, year):
814
  scaleratio=1
815
  ),
816
  xaxis=dict(
817
-
818
  tickmode='array',
819
  tickvals=month_positions,
820
  ticktext=month_labels,
@@ -836,7 +836,7 @@ def create_plot(username, year):
836
 
837
  fig.update_layout(
838
  xaxis=dict(fixedrange=True), # disable zoom and pan
839
- yaxis=dict(fixedrange=True)
840
  )
841
 
842
  return fig
 
737
 
738
  def create_plot(username, year):
739
  dates_in_year = get_dates_in_year(year)
 
740
  dates_in_year = [d.date() for d in dates_in_year]
741
 
742
  activity_data = get_user_likes(username)
 
747
  if date in activity_count:
748
  activity_count[date] += 1
749
 
750
+ total_activities = sum(activity_count.values())
751
+
752
  # activity->color
753
  def get_color(activity_count):
754
  if activity_count == 0:
 
763
  # data->Plotly
764
  num_weeks = len(dates_in_year) // 7 + (1 if len(dates_in_year) % 7 != 0 else 0)
765
 
766
+ z = [[None for _ in range(num_weeks)] for _ in range(7)]
767
  hover_texts = [["" for _ in range(num_weeks)] for _ in range(7)]
768
 
769
  for idx, date in enumerate(dates_in_year):
 
800
  ))
801
 
802
  # lock the plot size and ensure cells are square
803
+ cell_size = 20
804
  fig.update_layout(
805
+ title=f'{username} Activity in {year} | Total Contributions: {total_activities}',
806
  xaxis_nticks=52,
807
  yaxis_nticks=7,
808
  xaxis_title=' ',
 
815
  scaleratio=1
816
  ),
817
  xaxis=dict(
 
818
  tickmode='array',
819
  tickvals=month_positions,
820
  ticktext=month_labels,
 
836
 
837
  fig.update_layout(
838
  xaxis=dict(fixedrange=True), # disable zoom and pan
839
+ yaxis=dict(fixedrange=True) # disable zoom and pan
840
  )
841
 
842
  return fig