Skip to content

Commit 43b3f31

Browse files
authored
Merge pull request #44 from ONS-Innovation/lambda_endpoint_updates
KEH-718 | Lambda endpoint updates
2 parents 88c183b + ce354b8 commit 43b3f31

File tree

7 files changed

+32
-95
lines changed

7 files changed

+32
-95
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ site/
1919
# Local .terraform directories
2020
**/.terraform/*
2121

22+
.terraform.lock.hcl
23+
2224
# .tfstate files
2325
*.tfstate
2426
*.tfstate.*

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
A Streamlit dashboard to display information from the Github Copilot Usage API endpoints.
44

5+
---
6+
7+
## Important Notice
8+
9+
This repository is currently using depreciated endpoints to collect CoPilot Usage information and will not be able to show information past the 1st of February 2025.
10+
11+
We are working on refactoring the dashboard and its lambda to make use of the new endpoints and its data structure.
12+
13+
| Documentation | Link |
14+
| ------------- | ---- |
15+
| Old Endpoint | https://docs.github.com/en/rest/copilot/copilot-usage?apiVersion=2022-11-28 |
16+
| New Endpoint | https://docs.github.com/en/rest/copilot/copilot-metrics?apiVersion=2022-11-28 |
17+
18+
---
19+
520
## Disclaimer
621

722
### Early Stage & Accessibility Disclaimer

lambda_data_logger/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get_copilot_team_date(gh: github_api_toolkit.github_interface, page: int) ->
6262
response = gh.get(f"/orgs/{org}/teams", params={"per_page": 100, "page": page})
6363
teams = response.json()
6464
for team in teams:
65-
usage_data = gh.get(f"/orgs/{org}/team/{team['name']}/copilot/usage")
65+
usage_data = gh.get(f"/orgs/{org}/team/{team['name']}/copilot/metrics")
6666
try:
6767
if usage_data.json():
6868
copilot_teams.append(team["name"])
@@ -107,7 +107,7 @@ def handler(event, context):
107107
# CoPilot Usage Data (Historic)
108108

109109
# Get the usage data
110-
usage_data = gh.get(f"/orgs/{org}/copilot/usage")
110+
usage_data = gh.get(f"/orgs/{org}/copilot/metrics")
111111
usage_data = usage_data.json()
112112

113113
logger.info("Usage data retrieved")
@@ -124,11 +124,11 @@ def handler(event, context):
124124
dates_added = []
125125

126126
# Append the new usage data to the historic_usage_data.json
127-
for day in usage_data:
128-
if not any(d["day"] == day["day"] for d in historic_usage):
129-
historic_usage.append(day)
127+
for date in usage_data:
128+
if not any(d["date"] == date["date"] for d in historic_usage):
129+
historic_usage.append(date)
130130

131-
dates_added.append(day["day"])
131+
dates_added.append(date["date"])
132132

133133
logger.info(
134134
f"New usage data added to {object_name}",

src/pages/org_usage.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
# AWS Bucket Path
2626
bucket_name = f"{account}-copilot-usage-dashboard"
27-
object_name = "historic_usage_data.json"
27+
object_name = "historic_usage_data_pre_feb_25.json"
2828

2929

3030
@st.cache_data
@@ -54,6 +54,10 @@ def get_pem_from_secret_manager(_session: boto3.Session, secret_name: str, regio
5454

5555
col2.image("./src/branding/ONS_Logo_Digital_Colour_Landscape_Bilingual_RGB.png")
5656

57+
st.header("Important Notice")
58+
st.write("Due to an update to GitHub's APIs, this dashboard is currently only able to show data up to the **1st of February 2025**.")
59+
st.write("We are working on refactoring the dashboard to use the new API endpoints.")
60+
5761
live_tab, historic_tab = st.tabs(["Live Data", "Historic Data"])
5862

5963
with live_tab:

src/pages/team_usage.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ def initialize_states():
325325

326326
col2.image("./src/branding/ONS_Logo_Digital_Colour_Landscape_Bilingual_RGB.png")
327327

328+
st.header("Important Notice")
329+
st.write("Due to an update to GitHub's APIs, this dashboard is currently only able to show data up to the **1st of February 2025**.")
330+
st.write("We are working on refactoring the dashboard to use the new API endpoints.")
331+
328332
initialize_states()
329333

330334
# Step 1: GitHub Login

terraform/dashboard/.terraform.lock.hcl

Lines changed: 0 additions & 63 deletions
This file was deleted.

terraform/data_logger/.terraform.lock.hcl

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)