Skip to content
Closed
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
36 changes: 35 additions & 1 deletion .github/workflows/data-processing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,57 @@ jobs:
exit 1
fi
echo "✅ Credentials are set, running script..."

# Ensure data/ga_data directory exists
mkdir -p data/ga_data
echo "✅ data/ga_data directory created/verified"

# Run the script (it will create data/ga_data.json)
python scripts/download_ga_data.py
echo "✅ GA data download completed"

# Verify the file was created in the new location
if [ -f "data/ga_data/ga_data.json" ]; then
echo "✅ GA data file exists in data/ga_data/"
echo "File size: $(wc -c < data/ga_data/ga_data.json) bytes"
echo "File contents preview:"
head -5 data/ga_data/ga_data.json
else
echo "❌ GA data file was not created in data/ga_data/"
exit 1
fi

- name: Run Google Scholar script
continue-on-error: true # Continue even if this step fails
run: python3 scripts/gs-cite/google_scholar.py
env:
SERPAPI: ${{ secrets.SERPAPI }}

- name: Verify data before upload
run: |
echo "=== Verifying data before upload ==="
echo "Current directory: $(pwd)"
echo "Data directory contents:"
ls -la data/ || echo "Data directory does not exist"
echo "GA data directory contents:"
ls -la data/ga_data/ || echo "GA data directory does not exist"
if [ -f "data/ga_data/ga_data.json" ]; then
echo "✅ GA data file exists in data/ga_data/"
echo "File size: $(wc -c < data/ga_data/ga_data.json) bytes"
echo "File modified: $(stat -c %y data/ga_data/ga_data.json)"
else
echo "❌ GA data file missing from data/ga_data/"
fi

- name: Upload data artifact
uses: actions/upload-artifact@v4
with:
name: data-artifact
path: |
content/contributors/tenzing.md
content/curated_resources/
data/ # GA data
data/ga_data/ga_data.json # GA data
data/ # other
content/contributor-analysis/
content/publications/citation_chart.webp
retention-days: 1
1 change: 1 addition & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:

# Download GA data if possible
if [ "${{ github.event_name }}" != 'pull_request' ]; then
mkdir -p data/ga_data
python scripts/download_ga_data.py
fi

Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/ga_daily_visitors.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var dailyData = {{ .Site.Data.ga_data.daily_visitors | jsonify | safeJS }};
var dailyData = {{ .Site.Data.ga_data.ga_data.daily_visitors | jsonify | safeJS }};
if (dailyData && dailyData.length) {
dailyData.sort((a, b) => new Date(a.date) - new Date(b.date));
dailyData.pop();
Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/ga_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}).setView([40, 0], 1.25); // ✅ Adjust as needed

// ✅ Define visitor data from Hugo
var gaRegionsData = {{ .Site.Data.ga_data.regions | jsonify | safeJS }};
var gaRegionsData = {{ .Site.Data.ga_data.ga_data.regions | jsonify | safeJS }};
var gaRegions = {};
gaRegionsData.forEach(function(entry) {
gaRegions[entry.country] = entry.users;
Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/ga_top_pages.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</tr>
</thead>
<tbody>
{{ range .Site.Data.ga_data.top_pages }}
{{ range .Site.Data.ga_data.ga_data.top_pages }}
<tr>
<td>
{{ with .Site.GetPage .page }}
Expand Down
4 changes: 2 additions & 2 deletions scripts/download_ga_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
"daily_visitors": daily_visitors
}

os.makedirs("data", exist_ok=True)
with open("data/ga_data.json", "w") as f:
os.makedirs("data/ga_data", exist_ok=True)
with open("data/ga_data/ga_data.json", "w") as f:
json.dump(data, f, indent=2)

print("Google Analytics data downloaded and saved to data/ga_data.json")