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

v1 dev → main #344

Merged
merged 10 commits into from
Jul 2, 2024
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/client/ @joshuagraber
* @mbodeantor
* @josh-chamberlain
12 changes: 11 additions & 1 deletion client/src/components/SearchResultCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,17 @@ export default {
this.$router.push(`/data-sources/${this.dataSource.airtable_uid}`);
},
openSource() {
window.open(this.dataSource.source_url, '_blank');
let url = this.dataSource.source_url;
// ensure URL is treated as an absolute path
url = this.prepend_protocol_if_none(url)
window.open(url, '_blank');
},
prepend_protocol_if_none(url) {
// add 'https://' if the URL does not have a protocol
if (!/^https?:\/\//i.test(url)) {
return url = 'https://' + url;
}
return url;
},
formatDate: formatDateForSearchResults,
},
Expand Down
2 changes: 2 additions & 0 deletions middleware/initialize_psycopg2_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from psycopg2.extensions import connection as PgConnection
from typing import Union, Dict, List
from dotenv import load_dotenv


def initialize_psycopg2_connection() -> (
Expand All @@ -17,6 +18,7 @@ def initialize_psycopg2_connection() -> (
:return: A psycopg2 connection object if successful, or a dictionary with a count of 0 and an empty data list upon failure.
"""
try:
load_dotenv()
DO_DATABASE_URL = os.getenv("DO_DATABASE_URL")

return psycopg2.connect(
Expand Down
16 changes: 14 additions & 2 deletions regular_api_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,20 @@
response = requests.post(
f"{BASE_URL}/data-sources",
headers=HEADERS,
json={"name": "test", "record_type": "test"},
json={"name": "test", "record_type": "test", "test_flag": True},
)

assert response.json() == True
assert response.json()["message"] == "Data source added successfully."


def test_create_user_data_source():

Check warning on line 98 in regular_api_checks.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] regular_api_checks.py#L98 <103>

Missing docstring in public function
Raw output
./regular_api_checks.py:98:1: D103 Missing docstring in public function
response = requests.post(
f"{BASE_URL}/data-sources",
headers=HEADERS,
json={"name": "test", "record_type": "test", "approval_status": "intake"},

Check failure on line 102 in regular_api_checks.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] regular_api_checks.py#L102 <501>

line too long (82 > 79 characters)
Raw output
./regular_api_checks.py:102:80: E501 line too long (82 > 79 characters)
)

assert response.json()["message"] == "Data source added successfully."


def test_update_data_source():
Expand Down Expand Up @@ -301,6 +311,8 @@
"test_quicksearch_media_bulletin_pennsylvania_results",
"test_data_source_by_id",
"test_data_sources",
"test_create_data_source",
"test_create_user_data_source",
"test_update_data_source",
"test_data_sources_approved",
"test_data_source_by_id_approved",
Expand Down
15 changes: 9 additions & 6 deletions resources/DataSources.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def post(self) -> Dict[str, str]:
"approval_status",
"airtable_uid",
"airtable_source_last_modified",
"test_flag",
]

column_names = ""
Expand All @@ -157,15 +158,17 @@ def post(self) -> Dict[str, str]:
now = datetime.now().strftime("%Y-%m-%d")
airtable_uid = str(uuid.uuid4())

column_names += (
"approval_status, url_status, data_source_created, airtable_uid"
)
column_values += f"False, '[\"ok\"]', '{now}', '{airtable_uid}'"
if "approval_status" not in data:
column_names += "approval_status, "
column_values += "'intake', "
column_names += "url_status, data_source_created, airtable_uid"
column_values += f"'[\"ok\"]', '{now}', '{airtable_uid}'"

sql_query = f"INSERT INTO data_sources ({column_names}) VALUES ({column_values}) RETURNING *"

cursor.execute(sql_query)
self.psycopg2_connection.commit()
if "test_flag" not in data:
cursor.execute(sql_query)
self.psycopg2_connection.commit()

return {"message": "Data source added successfully."}

Expand Down
Loading