Skip to content

Commit

Permalink
Merge branch 'master' into feature/user_remove_temp
Browse files Browse the repository at this point in the history
  • Loading branch information
injoonH authored Feb 21, 2024
2 parents 7f8ddc7 + ec8f6f4 commit d53baf1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
13 changes: 7 additions & 6 deletions apps/core/management/scripts/portal_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def _get_new_url_and_save_to_s3(url, session):
hash = enc.hexdigest()[:20]
filename = f'files/portal_image_{hash}.{url.split("_")[-1]}'

if url.startswith("/board"):
url = str(BASE_URL) + url

r = session.get(url, stream=True, cookies=COOKIES)
if r.status_code == 200:
s3 = boto3.client("s3")
Expand All @@ -122,12 +125,10 @@ def _save_portal_image(html, session):
soup = bs(html, "lxml")
for child in soup.find_all("img", {}):
old_url = child.attrs.get("src")
try:
new_url = _get_new_url_and_save_to_s3(old_url, session)
child["src"] = new_url
except Exception as exc:
log.info(child)
raise exec
if old_url is None:
continue
new_url = _get_new_url_and_save_to_s3(old_url, session)
child["src"] = new_url

return str(soup)

Expand Down
7 changes: 0 additions & 7 deletions apps/core/migrations/0057_alter_article_name_type_and_more.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,4 @@ class Migration(migrations.Migration):
verbose_name="익명 혹은 실명 여부",
),
),
migrations.AddIndex(
model_name="article",
index=models.Index(
fields=["created_at", "parent_board_id"],
name="created_at_parent_board_id_idx",
),
),
]
7 changes: 0 additions & 7 deletions apps/core/models/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,6 @@ class Meta(MetaDataModel.Meta):
verbose_name = "게시물"
verbose_name_plural = "게시물 목록"

indexes = [
models.Index(
fields=["created_at", "parent_board_id"],
name="created_at_parent_board_id_idx",
)
]

def __str__(self):
return self.title

Expand Down

0 comments on commit d53baf1

Please sign in to comment.