lysandre HF staff commited on
Commit
6090892
1 Parent(s): a683ad3

Update repository statistics

Browse files
Files changed (2) hide show
  1. app.py +46 -11
  2. index.js +2 -0
app.py CHANGED
@@ -25,6 +25,8 @@ external_datasets = {
25
  "stars": load_dataset("open-source-metrics/stars-external"),
26
  "issues": load_dataset("open-source-metrics/issues-external")
27
  }
 
 
28
 
29
 
30
  def cut_output(full_output: Dataset, library_names: list):
@@ -45,6 +47,15 @@ def parse_name_and_options(path):
45
  return library_names, options
46
 
47
 
 
 
 
 
 
 
 
 
 
48
  class RequestHandler(SimpleHTTPRequestHandler):
49
  def do_GET(self):
50
  print(self.path)
@@ -98,13 +109,6 @@ class RequestHandler(SimpleHTTPRequestHandler):
98
  cumulated = '1' in options
99
  week_over_week = '2' in options
100
 
101
- def sum_of_lists(lists):
102
- def _sum(items):
103
- while None in items:
104
- items.remove(None)
105
- return sum(items)
106
-
107
- return [_sum(list(a)) for a in zip(*lists)]
108
 
109
  if week_over_week:
110
  if cumulated:
@@ -128,22 +132,53 @@ class RequestHandler(SimpleHTTPRequestHandler):
128
  if self.path.startswith("/retrieveStars"):
129
  library_names, options = parse_name_and_options(self.path)
130
  week_over_week = '1' in options
 
131
 
132
  if week_over_week:
133
- return self.response({k: v for k, v in datasets['stars']['wow'].to_dict().items() if k in library_names + ['day']})
 
 
 
 
 
 
 
134
  else:
135
- return self.response({k: v for k, v in datasets['stars']['raw'].to_dict().items() if k in library_names + ['day']})
 
 
 
 
 
 
 
 
136
 
137
  if self.path.startswith("/retrieveIssues"):
138
  library_names, options = parse_name_and_options(self.path)
139
  exclude_org_members = '1' in options
140
  week_over_week = '2' in options
 
141
 
142
  if week_over_week:
143
  if exclude_org_members:
144
- return self.response(cut_output(datasets['issues']['eom_wow'], library_names))
 
 
 
 
 
 
 
145
  else:
146
- return self.response({k: v for k, v in datasets['issues']['wow'].to_dict().items() if k in library_names + ['day']})
 
 
 
 
 
 
 
147
  else:
148
  if exclude_org_members:
149
  return self.response({k: v for k, v in datasets['issues']['eom'].to_dict().items() if k in library_names + ['day']})
 
25
  "stars": load_dataset("open-source-metrics/stars-external"),
26
  "issues": load_dataset("open-source-metrics/issues-external")
27
  }
28
+ external_datasets['pip']['openai_python'] = external_datasets['pip']['openai']
29
+ del external_datasets['pip']['openai']
30
 
31
 
32
  def cut_output(full_output: Dataset, library_names: list):
 
47
  return library_names, options
48
 
49
 
50
+ def sum_of_lists(lists):
51
+ def _sum(items):
52
+ while None in items:
53
+ items.remove(None)
54
+ return sum(items)
55
+
56
+ return [_sum(list(a)) for a in zip(*lists)]
57
+
58
+
59
  class RequestHandler(SimpleHTTPRequestHandler):
60
  def do_GET(self):
61
  print(self.path)
 
109
  cumulated = '1' in options
110
  week_over_week = '2' in options
111
 
 
 
 
 
 
 
 
112
 
113
  if week_over_week:
114
  if cumulated:
 
132
  if self.path.startswith("/retrieveStars"):
133
  library_names, options = parse_name_and_options(self.path)
134
  week_over_week = '1' in options
135
+ cumulated = '2' in options
136
 
137
  if week_over_week:
138
+ if cumulated:
139
+ cumulated_dict = {
140
+ 'Cumulated': sum_of_lists([v for k, v in datasets['stars']['wow'].to_dict().items() if k in library_names]),
141
+ 'day': datasets['stars']['wow'].to_dict()['day']
142
+ }
143
+ return self.response(cumulated_dict)
144
+ else:
145
+ return self.response({k: v for k, v in datasets['stars']['wow'].to_dict().items() if k in library_names + ['day']})
146
  else:
147
+ if cumulated:
148
+ cumulated_dict = {
149
+ 'Cumulated': sum_of_lists([v for k, v in datasets['stars']['raw'].to_dict().items() if k in library_names]),
150
+ 'day': datasets['stars']['raw'].to_dict()['day']
151
+ }
152
+ return self.response(cumulated_dict)
153
+ else:
154
+ return self.response({k: v for k, v in datasets['stars']['raw'].to_dict().items() if k in library_names + ['day']})
155
+
156
 
157
  if self.path.startswith("/retrieveIssues"):
158
  library_names, options = parse_name_and_options(self.path)
159
  exclude_org_members = '1' in options
160
  week_over_week = '2' in options
161
+ cumulated = '3' in options
162
 
163
  if week_over_week:
164
  if exclude_org_members:
165
+ if cumulated:
166
+ cumulated_dict = {
167
+ 'Cumulated': sum_of_lists([v for k, v in datasets['issues']['eom_wow'].to_dict().items() if k in library_names]),
168
+ 'day': datasets['issues']['eom_wow'].to_dict()['day']
169
+ }
170
+ return self.response(cumulated_dict)
171
+ else:
172
+ return self.response(cut_output(datasets['issues']['eom_wow'], library_names))
173
  else:
174
+ if cumulated:
175
+ cumulated_dict = {
176
+ 'Cumulated': sum_of_lists([v for k, v in datasets['issues']['wow'].to_dict().items() if k in library_names]),
177
+ 'day': datasets['issues']['wow'].to_dict()['day']
178
+ }
179
+ return self.response(cumulated_dict)
180
+ else:
181
+ return self.response({k: v for k, v in datasets['issues']['wow'].to_dict().items() if k in library_names + ['day']})
182
  else:
183
  if exclude_org_members:
184
  return self.response({k: v for k, v in datasets['issues']['eom'].to_dict().items() if k in library_names + ['day']})
index.js CHANGED
@@ -196,8 +196,10 @@ const initialize = async () => {
196
 
197
  addOption('issue', "Exclude org members");
198
  addOption('issue', "Week over week");
 
199
 
200
  addOption('stars', "Week over week");
 
201
 
202
  const fetchButton = createButton('Fetch', inferJson, () => {
203
  const graphNames = ['pip', 'stars', 'issue'].filter(e => document.querySelector(`#${e}CheckboxGraph`).checked);
 
196
 
197
  addOption('issue', "Exclude org members");
198
  addOption('issue', "Week over week");
199
+ addOption('issue', "Cumulated");
200
 
201
  addOption('stars', "Week over week");
202
+ addOption('stars', "Cumulated");
203
 
204
  const fetchButton = createButton('Fetch', inferJson, () => {
205
  const graphNames = ['pip', 'stars', 'issue'].filter(e => document.querySelector(`#${e}CheckboxGraph`).checked);