Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Failed run due to IndexError #64

Merged
merged 4 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [v0.4.3](https://github.com/astrochun/github-stats-pages/tree/v0.4.3) (2021-07-05)

**Fixed bugs:**
- Bug: Failed run due to IndexError
[#63](https://github.com/astrochun/github-stats-pages/issues/63)

**Merged pull requests:**
- Bug: Failed run due to IndexError
[#64](https://github.com/astrochun/github-stats-pages/pull/64)


## [v0.4.2](https://github.com/astrochun/github-stats-pages/tree/v0.4.2) (2021-06-27)

**Fixed bugs:**
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,22 @@ Note: While a GitHub profile README does not work for an organization in the sam
individual GitHub accounts, this software will still use its content if it is publicly available.
Here's an [example](https://ual-odis.github.io/github-stats/)

### 3. What happens when I renamed a repository?

This software will retrieve the latest list of public repositories. When the
statistics pages are then generated, it searches the `data/` folder for the
information for each repo. As such, there is an issue with renaming of
repositories. This will be apparent in the logs with the following warnings:
```
WARNING: Possible issue with repository name, ...
If you renamed it, you will need to update data/ contents
```

To rectify this issue, you can `git clone` your GitHub repository, and rename
each occurrence of the old repositories with the new ones using your preferred
IDE or command-line options (e.g., `sed`). Then `git add`, `git commit`, and
`git push` these changes. The next scheduled run will then work as intended.

## Versioning

## Continuous Integration
Expand Down
2 changes: 1 addition & 1 deletion github_stats_pages/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.2"
__version__ = "0.4.3"
78 changes: 41 additions & 37 deletions github_stats_pages/stats_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,56 +261,60 @@ def make_plots(username: str, data_dir: str, out_dir: str, csv_file: str,
for r in final_repo_names:
t_r_df = repository_df.loc[repository_df['name'] == r]

r_traffic_df = traffic_df.loc[traffic_df[columns[0]] == r]
r_clone_df = clone_df.loc[clone_df[columns[0]] == r]
r_referrer_df = referrer_df.loc[referrer_df[columns[0]] == r]
if len(t_r_df) == 0:
print(f"WARNING: Possible issue with repository name, {r}")
print(f"If you renamed it, you will need to update data/ contents")
else:
r_traffic_df = traffic_df.loc[traffic_df[columns[0]] == r]
r_clone_df = clone_df.loc[clone_df[columns[0]] == r]
r_referrer_df = referrer_df.loc[referrer_df[columns[0]] == r]

date_range = get_date_range([r_traffic_df, r_clone_df])
date_range = get_date_range([r_traffic_df, r_clone_df])

subplots_dict = dict(pw=pw, ph=ph, bc=bc, bfc=bfc)
subplots_dict = dict(pw=pw, ph=ph, bc=bc, bfc=bfc)

# Plot traffic data
s1a = date_subplots(r_traffic_df, 'total', date_range,
'Total Daily Traffic', **subplots_dict)
# Plot traffic data
s1a = date_subplots(r_traffic_df, 'total', date_range,
'Total Daily Traffic', **subplots_dict)

s1b = date_subplots(r_traffic_df, 'unique', date_range,
'Unique Daily Traffic', **subplots_dict)
s1b = date_subplots(r_traffic_df, 'unique', date_range,
'Unique Daily Traffic', **subplots_dict)

# Plot clones traffic
s2a = date_subplots(r_clone_df, 'total', date_range,
'Total Daily Clones', **subplots_dict)
# Plot clones traffic
s2a = date_subplots(r_clone_df, 'total', date_range,
'Total Daily Clones', **subplots_dict)

s2b = date_subplots(r_clone_df, 'unique', date_range,
'Unique Daily Clones', **subplots_dict)
s2b = date_subplots(r_clone_df, 'unique', date_range,
'Unique Daily Clones', **subplots_dict)

s3a = refer_subplots(r_referrer_df, 'total', 'Total Referrals',
**subplots_dict)
s3a = refer_subplots(r_referrer_df, 'total', 'Total Referrals',
**subplots_dict)

s3b = refer_subplots(r_referrer_df, 'unique', 'Unique Referrals',
**subplots_dict)
s3b = refer_subplots(r_referrer_df, 'unique', 'Unique Referrals',
**subplots_dict)

grid = gridplot([[s1a, s1b], [s2a, s2b], [s3a, s3b]],
plot_width=pw, plot_height=ph)
grid = gridplot([[s1a, s1b], [s2a, s2b], [s3a, s3b]],
plot_width=pw, plot_height=ph)

script, div = components(grid)
script, div = components(grid)

jinja_dict = {
'username': username,
'title': f"GitHub Statistics for {r}",
'Total_Views': r_traffic_df['total'].sum(),
'Total_Clones': r_clone_df['total'].sum(),
'script': script,
'div': div,
'repos': sorted(final_repo_names),
'avatar_url': avatar_response['avatar_url'],
}
jinja_dict.update(t_r_df.to_dict(orient='records')[0])
jinja_dict = {
'username': username,
'title': f"GitHub Statistics for {r}",
'Total_Views': r_traffic_df['total'].sum(),
'Total_Clones': r_clone_df['total'].sum(),
'script': script,
'div': div,
'repos': sorted(final_repo_names),
'avatar_url': avatar_response['avatar_url'],
}
jinja_dict.update(t_r_df.to_dict(orient='records')[0])

t = env.get_template('page.html')
t = env.get_template('page.html')

out_file = p_repos / f"{r}.html"
with open(out_file, 'w') as f:
f.writelines(t.render(jinja_dict=jinja_dict))
out_file = p_repos / f"{r}.html"
with open(out_file, 'w') as f:
f.writelines(t.render(jinja_dict=jinja_dict))


def get_final_repo_names(p_repos: Path, repo_names: set,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='github-stats-pages',
version='0.4.2',
version='0.4.3',
packages=['github_stats_pages'],
scripts=['scripts/get_repo_list',
'scripts/gts_run_all_repos',
Expand Down