-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17b576e
commit da952fa
Showing
3 changed files
with
253 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
demos/20240315_BOBKonf_2024/extremely_ugly_script_to_get_the_files_per_commit_via_git_log.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
# Define the repository directory | ||
REPO_DIR="../../angular/" | ||
|
||
# Move to the repository directory | ||
cd "$REPO_DIR" || exit | ||
|
||
# Print CSV header as first line | ||
echo "sha,timestamp,action,file_path" | ||
|
||
# create variables for the repeated information per file | ||
commit_hash="" | ||
commit_timestamp="" | ||
|
||
# Git log all the things and iterate through each commit | ||
git log --pretty=format:"INFO,%H,%at" --date=format:"%Y-%m-%d %H:%M:%S" --name-status --diff-filter=ADR -- '*.ts' '*.js' | while read -r line; do | ||
|
||
if [[ "$line" =~ "INFO" ]]; then | ||
commit_hash=$(echo "$line" | cut -d ',' -f 2) | ||
commit_timestamp=$(echo "$line" | cut -d ',' -f 3) | ||
fi | ||
|
||
# Check if the line contains actions for add and delete | ||
if [[ "$line" =~ ^[AD] ]]; then | ||
|
||
action=$(echo "$line" | cut -d$'\t' -f 1) | ||
file_path=$(echo "$line" | cut -d$'\t' -f 2) | ||
|
||
# Print commit information in CSV format | ||
echo "$commit_hash,$commit_timestamp,$action,$file_path" | ||
fi | ||
|
||
# Treat rename as add and delete action | ||
if [[ "$line" =~ ^[R] ]]; then | ||
|
||
action="D" | ||
file_path=$(echo "$line" | cut -d$'\t' -f 2) | ||
|
||
echo "$commit_hash,$commit_timestamp,$action,$file_path" | ||
|
||
action="A" | ||
file_path=$(echo "$line" | cut -d$'\t' -f 3) | ||
|
||
echo "$commit_hash,$commit_timestamp,$action,$file_path" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import pandas as pd | ||
from matplotlib.colors import rgb2hex | ||
from matplotlib import cm | ||
import json | ||
import os | ||
from IPython.core.display import HTML | ||
|
||
|
||
|
||
# preprocess data for plotting | ||
def create_plot_data(df, color_column_name, size_column_name, seperator): | ||
plot_data = pd.DataFrame(index=df.index) | ||
plot_data['value_for_color'] = df[color_column_name] | ||
plot_data['ratio_for_color'] = plot_data['value_for_color'] / plot_data['value_for_color'].max() | ||
plot_data['color'] = plot_data['ratio_for_color'].apply(lambda x : rgb2hex(cm.coolwarm(x))) | ||
plot_data['size'] = df[size_column_name] | ||
plot_data[['path', 'name']] = df.index.str.rsplit(seperator, n=1).to_list() | ||
plot_data['path_list'] = plot_data['path'].str.split(seperator) | ||
return plot_data | ||
|
||
|
||
# convert to d3 data format | ||
def create_flare_json(df): | ||
|
||
json_data = {'name': 'flare', 'children': []} | ||
|
||
for _, series in df.iterrows(): | ||
hierarchical_data = series['path_list'] | ||
|
||
children = json_data['children'] | ||
for part in hierarchical_data: | ||
entry = next((child for child in children if child.get('name', '') == part), None) | ||
if not entry: | ||
entry = {'name': part, 'children': []} | ||
children.append(entry) | ||
children = entry['children'] | ||
|
||
children.append({ | ||
'name': f"{series['name']} ({series['size']} [{series['value_for_color']}])", | ||
'size': series['size'], | ||
'color': series['color'] | ||
}) | ||
|
||
return json_data | ||
|
||
|
||
# Put data into template | ||
def create(hotspots, color_column_name, size_column_name, separator): | ||
json_data = create_flare_json(create_plot_data(hotspots, color_column_name, size_column_name,separator)) | ||
|
||
with open("vis/template_circle_pack_hierarchy_chart_d3_inline.html") as html_template: | ||
html = html_template.read().replace("###JSON###", str(json_data)) | ||
|
||
os.makedirs("output", exist_ok=True) | ||
with open(f'output/hotspots.html', mode='w') as html_out: | ||
html_out.write(html) | ||
|
||
return HTML('<a href="output/hotspots.html" target="_blank">Production Coverage Hotspots</a>') |
148 changes: 148 additions & 0 deletions
148
demos/20240315_BOBKonf_2024/vis/template_circle_pack_hierarchy_chart_d3_inline.html
Large diffs are not rendered by default.
Oops, something went wrong.