Skip to content

Commit

Permalink
feat: add build stats (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleretters authored Jul 1, 2023
1 parent e010d7d commit 6f08ab0
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion 02-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
explore_dist = '_pages/explore.md'
about_dist = '_pages/about.md'
github_raw_url_template = 'https://raw.githubusercontent.com/GITHUB_AUTHOR/GITHUB_PROJECT/HEAD'
remote_cover_count = 0
local_cover_count = 0
missing_cover_count = 0
remote_readme_count = 0
missing_readme_count = 0


# CLASSES
# CLASSES
Expand Down Expand Up @@ -169,6 +175,7 @@ def fetch(self):
with open(destination, 'wb') as f:
f.write(response.content)
log('saved to ' + destination)
remote_cover_count += 1
cover_found = True
break
except requests.exceptions.RequestException as e:
Expand All @@ -182,11 +189,13 @@ def fetch(self):
command = 'cp ' + path + ' ' + destination
subprocess.Popen(command, shell=True)
log('saved to ' + destination)
local_cover_count += 1
cover_found = True
if not cover_found:
log('no cover found. using dust.')
command = 'cp ./assets/images/dust.png' + ' ' + destination
subprocess.Popen(command, shell=True)
missing_cover_count += 1

class Readmes():

Expand Down Expand Up @@ -217,6 +226,7 @@ def fetch(self):
with open(destination, 'wb') as f:
f.write(response.content)
log('saved to ' + destination)
remote_readme_count += 1
readme_found = True
break
except requests.exceptions.RequestException as e:
Expand All @@ -227,6 +237,7 @@ def fetch(self):
if not readme_found:
log('could not find a readme')
open(destination, 'a')
missing_readme_count += 1

# FUNCTIONS
# FUNCTIONS
Expand Down Expand Up @@ -466,11 +477,23 @@ def build_about_page(about_dist):
fp.close()
log('done.')

def log_stats(community_data):
log('################################')
log('norns.community stats')
log('authors: ' + str(len(community_data.authors)))
log('projects: ' + str(len(community_data.projects)))
log('remote covers: ' + str(remote_cover_count))
log('local covers: ' + str(local_cover_count))
log('missing covers: ' + str(missing_cover_count))
log('remote readmes: ' + str(remote_readme_count))
log('missing readmes: ' + str(missing_readme_count))

# MAIN
# MAIN
# MAIN

log('starting at ' + datetime.datetime.now().strftime("%a %b %d %H:%M:%S %Z %Y"))
time_start = datetime.datetime.now()
log('starting at ' + time_start.strftime("%a %b %d %H:%M:%S %Z %Y"))
build_hash()
build_setup()
community_data = community_data_factory()
Expand All @@ -482,3 +505,7 @@ def build_about_page(about_dist):
build_tag_pages(community_data, tags_dist)
build_explore_page(community_data, explore_dist)
build_about_page(about_dist)
log_stats(community_data)
runtime = datetime.datetime.now() - time_start
log('finishing at ' + datetime.datetime.now().strftime("%a %b %d %H:%M:%S %Z %Y"))
log('total runtime ' + runtime.__str__())

0 comments on commit 6f08ab0

Please sign in to comment.