Skip to content

Commit

Permalink
get the gc-org data from s3
Browse files Browse the repository at this point in the history
  • Loading branch information
smcmurtry committed Jan 24, 2025
1 parent 861de16 commit 5f19f99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
7 changes: 3 additions & 4 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ class Config(object):
SALESFORCE_USERNAME = os.getenv("SALESFORCE_USERNAME")
SALESFORCE_PASSWORD = os.getenv("SALESFORCE_PASSWORD")
SALESFORCE_SECURITY_TOKEN = os.getenv("SALESFORCE_SECURITY_TOKEN")
CRM_GITHUB_PERSONAL_ACCESS_TOKEN = os.getenv("CRM_GITHUB_PERSONAL_ACCESS_TOKEN")
CRM_ORG_LIST_URL = os.getenv("CRM_ORG_LIST_URL")
GC_ORGANISATIONS_BUCKET_NAME = os.getenv("GC_ORGANISATIONS_BUCKET_NAME")
GC_ORGANISATIONS_FILENAME = os.getenv("GC_ORGANISATIONS_FILENAME", "all.json")

# Logging
DEBUG = False
Expand Down Expand Up @@ -748,9 +748,8 @@ class Test(Development):
API_HOST_NAME = "http://localhost:6011"

TEMPLATE_PREVIEW_API_HOST = "http://localhost:9999"
CRM_GITHUB_PERSONAL_ACCESS_TOKEN = "test-token"
CRM_ORG_LIST_URL = "https://test-url.com"
FAILED_LOGIN_LIMIT = 0
GC_ORGANISATIONS_BUCKET_NAME = "test-gc-organisations"


class Production(Config):
Expand Down
13 changes: 6 additions & 7 deletions app/service/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
from typing import Optional

import requests
from app.aws.s3 import get_s3_file
from flask import current_app
from notifications_utils.recipients import allowed_to_send_to
from sqlalchemy.orm.exc import NoResultFound
Expand Down Expand Up @@ -68,14 +68,13 @@ def safelisted_members(service, key_type, is_simulated=False, allow_safelisted_r


def get_gc_organisation_data() -> list[dict]:
"Returns the dataset from the gc-organisations repo"
response = requests.get(
current_app.config["CRM_ORG_LIST_URL"],
headers={"Authorization": f'token {current_app.config["CRM_GITHUB_PERSONAL_ACCESS_TOKEN"]}'},
"Returns the dataset from the gc-organisations repo, which we cache in s3"
file_data = get_s3_file(
current_app.config["GC_ORGANISATION_DATA_BUCKET_NAME"],
current_app.config["GC_ORGANISATIONS_FILENAME"],
)
response.raise_for_status()

account_data = json.loads(response.text)
account_data = json.loads(file_data)
return account_data


Expand Down

0 comments on commit 5f19f99

Please sign in to comment.