Skip to content

Commit 455b4c7

Browse files
committed
some comments
1 parent 848d696 commit 455b4c7

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

.github/workflows/get-metrics.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from google.analytics.data_v1beta import BetaAnalyticsDataClient
1212
from google.analytics.data_v1beta.types import DateRange, Dimension, Metric, RunReportRequest
1313

14-
PORTAL_ID = os.environ['PORTAL_ID']
15-
FOUNDATIONS_ID = os.environ['FOUNDATIONS_ID']
16-
COOKBOOKS_ID = os.environ['COOKBOOKS_ID']
14+
PORTAL_ID = '266784902'
15+
FOUNDATIONS_ID = '281776420'
16+
COOKBOOKS_ID = '324070631'
1717

1818
PRIVATE_KEY_ID = os.environ.get('PRIVATE_KEY_ID')
1919
PRIVATE_KEY = os.environ.get('PRIVATE_KEY')
@@ -34,6 +34,8 @@
3434

3535
client = BetaAnalyticsDataClient.from_service_account_info(credentials_dict)
3636

37+
pre_project_date = '2020-03-31' # random date before project start
38+
3739

3840
def _format_rounding(value):
3941
return f'{round(value / 1000, 1):.1f}K'
@@ -44,7 +46,7 @@ def _run_total_users_report(property_id):
4446
property=f'properties/{property_id}',
4547
dimensions=[],
4648
metrics=[Metric(name='activeUsers')],
47-
date_ranges=[DateRange(start_date='2020-03-31', end_date='today')],
49+
date_ranges=[DateRange(start_date=pre_project_date, end_date='today')],
4850
)
4951
response = client.run_report(request)
5052

@@ -110,7 +112,7 @@ def _run_top_pages_report(property_id):
110112
request = RunReportRequest(
111113
property=f'properties/{property_id}',
112114
dimensions=[Dimension(name='pageTitle')],
113-
date_ranges=[DateRange(start_date='2020-03-31', end_date='today')],
115+
date_ranges=[DateRange(start_date=pre_project_date, end_date='today')],
114116
metrics=[Metric(name='screenPageViews')],
115117
)
116118
response = client.run_report(request)
@@ -167,7 +169,7 @@ def _run_usersXcountry_report(property_id):
167169
property=f'properties/{property_id}',
168170
dimensions=[Dimension(name='country')],
169171
metrics=[Metric(name='activeUsers')],
170-
date_ranges=[DateRange(start_date='2020-03-31', end_date='today')],
172+
date_ranges=[DateRange(start_date=pre_project_date, end_date='today')],
171173
)
172174
response = client.run_report(request)
173175

@@ -183,6 +185,7 @@ def _run_usersXcountry_report(property_id):
183185
def plot_usersXcountry(FOUNDATIONS_ID):
184186
users_by_country = _run_usersXcountry_report(FOUNDATIONS_ID)
185187

188+
# Google API Country names do not match Cartopy Country Shapefile names
186189
dict_api2cartopy = {
187190
'Tanzania': 'United Republic of Tanzania',
188191
'United States': 'United States of America',

.github/workflows/nightly-build.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ jobs:
1212
- uses: actions/checkout@v3
1313
- name: Automate Metrics
1414
env:
15-
PORTAL_ID: ${{ secrets.PORTAL_ID }}
16-
FOUNDATIONS_ID: ${{ secrets.FOUNDATIONS_ID }}
17-
COOKBOOKS_ID: ${{ secrets.COOKBOOKS_ID }}
1815
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
1916
PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }}
2017
run: |

.github/workflows/publish-site.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ jobs:
1414
- uses: actions/checkout@v3
1515
- name: Automate Metrics
1616
env:
17-
PORTAL_ID: ${{ secrets.PORTAL_ID }}
18-
FOUNDATIONS_ID: ${{ secrets.FOUNDATIONS_ID }}
19-
COOKBOOKS_ID: ${{ secrets.COOKBOOKS_ID }}
2017
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
2118
PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }}
2219
run: |

.github/workflows/trigger-preview.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ jobs:
1414
- uses: actions/checkout@v3
1515
- name: Automate Metrics
1616
env:
17-
PORTAL_ID: ${{ secrets.PORTAL_ID }}
18-
FOUNDATIONS_ID: ${{ secrets.FOUNDATIONS_ID }}
19-
COOKBOOKS_ID: ${{ secrets.COOKBOOKS_ID }}
2017
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
2118
PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }}
2219
run: |

0 commit comments

Comments
 (0)