From f06ce2427ce4824e229971c5f2e42b7a49a0f641 Mon Sep 17 00:00:00 2001 From: dnicodemus-la Date: Wed, 13 Sep 2023 09:10:10 -0400 Subject: [PATCH 1/3] add unique field to text data --- fetch_stats.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/fetch_stats.py b/fetch_stats.py index fc9dc3e..eae162e 100644 --- a/fetch_stats.py +++ b/fetch_stats.py @@ -2,6 +2,9 @@ # Created: 4 June,2020, 8:02 PM # Email: aqeel.anwar@gatech.edu +import json +from pprint import pprint + from github import Github import datetime import csv @@ -78,6 +81,7 @@ date_array = [] clone_array = {} traffic_array = {} + unique_array = {} # Generate array of dates under consideration for d in range(14): @@ -85,6 +89,7 @@ # Assign zeros to clone and views statistics clone_array[latest_date] = 0 traffic_array[latest_date] = 0 + unique_array[latest_date] = 0 # Populate the clone statistics for the available date. # For unavailable dates, the stat is already initialized to zero @@ -94,6 +99,9 @@ for v in traffic_stat: traffic_array[str(v.timestamp.date())] = v.count + for v in traffic_stat: + unique_array[str(v.timestamp.date())] = v.uniques + # Create the folder of username if it doesn't exists path_to_folder = "repo_stats/" + args.username if not os.path.exists(path_to_folder): @@ -110,12 +118,15 @@ csv_file = open(csv_str, "w") writer = csv.writer(csv_file) # Define header of the CSV file - writer.writerow(["Date", "Clones", "Traffic"]) + writer.writerow(["Date", "Clones", "Traffic", "Unique"]) clone_array = OrderedDict(sorted(clone_array.items(), key=lambda t: t[0])) traffic_array = OrderedDict( sorted(traffic_array.items(), key=lambda t: t[0]) ) + unique_array = OrderedDict( + sorted(unique_array.items(), key=lambda t: t[0]) + ) if os.path.exists(csv_str_temp): # copyfile(csv_str, csv_str_temp) @@ -138,10 +149,10 @@ break line_count += 1 - for (key_clone, value_clone), (key_traffic, value_traffic) in zip( - clone_array.items(), traffic_array.items() + for (key_clone, value_clone), (key_traffic, value_traffic), (key_uinique, value_unique)in zip( + clone_array.items(), traffic_array.items(), unique_array.items() ): - writer.writerow([key_clone, value_clone, value_traffic]) + writer.writerow([key_clone, value_clone, value_traffic, value_unique]) csv_file.close() @@ -156,5 +167,3 @@ # Remove temp file. os.remove(csv_str_temp) - - From baeb4e8b2099ec32c64c51014eceac93671907a4 Mon Sep 17 00:00:00 2001 From: dnicodemus-la Date: Wed, 13 Sep 2023 09:12:36 -0400 Subject: [PATCH 2/3] remove pprint,json imports --- fetch_stats.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/fetch_stats.py b/fetch_stats.py index eae162e..11e28bd 100644 --- a/fetch_stats.py +++ b/fetch_stats.py @@ -2,9 +2,6 @@ # Created: 4 June,2020, 8:02 PM # Email: aqeel.anwar@gatech.edu -import json -from pprint import pprint - from github import Github import datetime import csv From 69af668227c3057c38ad4f35f6ccb8910fe3d3bf Mon Sep 17 00:00:00 2001 From: dnicodemus-la Date: Mon, 18 Sep 2023 10:51:20 -0400 Subject: [PATCH 3/3] fix so that copies have the unique column as well --- fetch_stats.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fetch_stats.py b/fetch_stats.py index 11e28bd..3c325b2 100644 --- a/fetch_stats.py +++ b/fetch_stats.py @@ -2,6 +2,9 @@ # Created: 4 June,2020, 8:02 PM # Email: aqeel.anwar@gatech.edu +import json +from pprint import pprint + from github import Github import datetime import csv @@ -141,7 +144,7 @@ ).date() if datetime_obj < compare_date: - writer.writerow([row[0], row[1], row[2]]) + writer.writerow([row[0], row[1], row[2], row[3]]) else: break line_count += 1 @@ -159,7 +162,7 @@ with open(csv_str) as csv_file: csv_reader = csv.reader(csv_file, delimiter=",") for row in csv_reader: - writer.writerow([row[0], row[1], row[2]]) + writer.writerow([row[0], row[1], row[2], row[3]]) csv_file.close() # Remove temp file.