Skip to content

Commit

Permalink
Fixing up codacy issues, removing unused values
Browse files Browse the repository at this point in the history
  • Loading branch information
jonespm committed Apr 1, 2024
1 parent 8cb0df4 commit ac7d041
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
3 changes: 1 addition & 2 deletions dashboard/common/db_util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Some utility functions used by other classes in this project
import logging
from datetime import datetime
from typing import Dict, List, Literal, TypedDict, Union
from typing import Any, Dict, List, Literal, TypedDict, Union
from urllib.parse import quote_plus

import django
Expand All @@ -12,7 +12,6 @@
from django.contrib.auth.models import User as DjangoUser
from django_cron.models import CronJobLog
from google.cloud import bigquery
from typing import Any, Dict, List

from dashboard.models import Course, User

Expand Down
9 changes: 3 additions & 6 deletions dashboard/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ def __init__(self) -> None:
self.myla_engine = db_util.create_sqlalchemy_engine(settings.DATABASES['default'])
self.setup_bigquery()
self.setup_queries()

queries = dict()
self.valid_locked_course_ids: List[str]

# Split a list into *size* shorter pieces
Expand Down Expand Up @@ -88,18 +86,17 @@ def util_function(self, sql_string, mysql_table, params=None, table_identifier=N
# Execute a query against the bigquery database

def execute_bq_query(self, query: str, params: Dict = None):
ext_context_store = settings.EXTERNAL_CONTEXT_STORE
# Remove the newlines from the query
query = query.replace("\n", " ")

if params:
try:
try:
# Convert to bq schema object
query_params= db_util.map_dict_to_query_job_config(params)
query_job_config = bigquery.QueryJobConfig(query_parameters=query_params)
query_job = self.bigquery_client.query(query, job_config=query_job_config)
query_job_result = query_job.result()

self.total_bytes_billed += query_job.total_bytes_billed
logger.debug(f"This job had {query_job.total_bytes_billed} bytes. Total: {self.total_bytes_billed}")
return query_job_result
Expand Down Expand Up @@ -509,7 +506,7 @@ def submission(self):
'canvas_data_id_increment': settings.CANVAS_DATA_ID_INCREMENT,
}

df = result = self.execute_bq_query(self.queries['submission'], query_params).to_dataframe()
df = self.execute_bq_query(self.queries['submission'], query_params).to_dataframe()
df = df.drop_duplicates(keep='first')
df.to_sql(con=self.myla_engine, name='submission', if_exists='append', index=False)

Expand Down
3 changes: 0 additions & 3 deletions dashboard/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ def apply_env_overrides(env: Dict[str, Any], environ: os._Environ) -> Dict[str,
**ENV.get('LRS', {})
}

# TODO: Replace this with a more generic value
EXTERNAL_CONTEXT_STORE = ENV.get("EXTERNAL_CONTEXT_STORE", "udp-umich-prod.us.context_store")

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

# Internationalization
Expand Down

0 comments on commit ac7d041

Please sign in to comment.