Skip to content

Commit

Permalink
Add total return articles limit
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinbhou committed Nov 30, 2020
1 parent 71b6f15 commit c47408d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ class ARTICLE_TYPE(Enum):

BUILD_FROM_SCRATCH = False
BACKEND_CORS_ORIGINS = ["*"]

MAX_NUMBER_OF_ARTICLES = 500
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def list_programs(student: Candidate) -> List[Article]:
articles = query_similar_background_api(query_dict)
print('Query:', query_dict)
max_score = articles[0].score if articles and articles[0].score else 0
for idx, article in enumerate(articles):
for idx, article in enumerate(articles[:settings.MAX_NUMBER_OF_ARTICLES]):
if article.score is None or (len(articles) > 100 and article.score < max_score // 2):
break
programs = init_programs(article)
Expand All @@ -55,7 +55,7 @@ def list_target_school_info(student: Candidate) -> List[Article]:
query_dict = parse_request(student, article_type="ADMISSION")
articles = query_target_school_api(query_dict)
max_score = articles[0].score if articles and articles[0].score else 0
for idx, article in enumerate(articles):
for idx, article in enumerate(articles[:settings.MAX_NUMBER_OF_ARTICLES]):
if article.score is None or (len(articles) > 100 and article.score != max_score):
break
programs = init_programs(article)
Expand Down

0 comments on commit c47408d

Please sign in to comment.