Skip to content

Commit

Permalink
[fix] Fixed handle update failed problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
yoneyan committed Dec 13, 2023
1 parent 601ff1c commit 0759247
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
38 changes: 23 additions & 15 deletions jpnic_admin/resource/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ def get_resource(self):

# 資源情報(main)
if (
latest_res_list is None
or latest_res_list.assigned_addr_count != info_resource_list.get("assigned_addr_count")
or latest_res_list.all_addr_count != info_resource_list.get("all_addr_count")
or latest_res_list.update_date != info_resource_list.get("update_date")
latest_res_list is None
or latest_res_list.assigned_addr_count != info_resource_list.get("assigned_addr_count")
or latest_res_list.all_addr_count != info_resource_list.get("all_addr_count")
or latest_res_list.update_date != info_resource_list.get("update_date")
):
self.insert_resource_list(info=info_resource_list, html=soup.prettify())
else:
Expand All @@ -230,10 +230,10 @@ def get_resource(self):
is_new_item = True
for latest_res_addr in latest_res_addr_list:
if (
latest_res_addr.ip_address == res_addr_list_one.get("ip_address")
and latest_res_addr.all_addr_count == res_addr_list_one.get("all_addr_count")
and latest_res_addr.assign_date == res_addr_list_one.get("assign_date")
and latest_res_addr.assigned_addr_count == res_addr_list_one.get("assigned_addr_count")
latest_res_addr.ip_address == res_addr_list_one.get("ip_address")
and latest_res_addr.all_addr_count == res_addr_list_one.get("all_addr_count")
and latest_res_addr.assign_date == res_addr_list_one.get("assign_date")
and latest_res_addr.assigned_addr_count == res_addr_list_one.get("assigned_addr_count")
):
latest_res_addr.last_checked_at = self.now
latest_res_addr.save()
Expand Down Expand Up @@ -331,9 +331,9 @@ def search_list(self):
# last_checked更新listの判定
for addr_list in addr_lists:
if (
addr_list.ip_address == addr_info["ip_address"]
and addr_list.division == addr_info["kind2"]
and addr_list.recep_number == addr_info["recept_no"]
addr_list.ip_address == addr_info["ip_address"]
and addr_list.division == addr_info["kind2"]
and addr_list.recep_number == addr_info["recept_no"]
):
is_exist_addr_lists = True
# 存在する場合は確認OKなので、last_checkedを更新する
Expand All @@ -350,9 +350,9 @@ def search_list(self):
# print("update_info_lists", len(update_info_lists))
# print("date_update_info_only_lists", len(date_update_info_only_lists))
if (
(not self.base.option_collection_no_filter)
and len(addr_lists) != 0
and len(date_update_info_only_lists) == 0
(not self.base.option_collection_no_filter)
and len(addr_lists) != 0
and len(date_update_info_only_lists) == 0
):
return

Expand Down Expand Up @@ -756,6 +756,7 @@ def update_handle(self):
handle_info["recep_number"] = info["recept_no"]
self.update_latest_data(handles=[].append(handle_info))

# ハンドル系の最新日付アップデート処理
def update_latest_data(self, handles=None):
last_handle = JPNICHandle.objects.filter(jpnic_id=self.base.id).order_by("-last_checked_at").first()
base_handle_lists = []
Expand All @@ -769,7 +770,7 @@ def update_latest_data(self, handles=None):
for base_handle in base_handle_lists:
is_exists = False
for input_handle in handles:
if input_handle["jpnic_handle"] == base_handle.jpnic_handle:
if check_handle(input_handle, base_handle.jpnic_handle):
is_exists = True
break
if not is_exists:
Expand All @@ -781,3 +782,10 @@ def update_latest_data(self, handles=None):
for handle_update in handle_update_lists:
handle_update.last_checked_at = self.now
JPNICHandle.objects.bulk_update(handle_update_lists, fields=["last_checked_at"])


def check_handle(target_handle, base_jpnic_handle):
if 'jpnic_handle' in target_handle:
return target_handle["jpnic_handle"] == base_jpnic_handle
else:
return target_handle["jpnic_hdl"] == base_jpnic_handle
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ beautifulsoup4==4.12.2
certifi==2023.11.17
cffi==1.16.0
charset-normalizer==3.3.2
cryptography==41.0.7
cryptography==41.0.5
decorator==5.1.1
Django==4.2.7
django-configurations==2.5
Expand All @@ -13,7 +13,7 @@ django-mathfilters==1.0.0
django-widget-tweaks==1.5.0
et-xmlfile==1.1.0
gunicorn==21.2.0
idna==3.6
idna==3.4
isodate==0.6.1
lxml==4.9.3
mysqlclient==2.2.0
Expand All @@ -26,7 +26,7 @@ pytz-deprecation-shim==0.1.0.post0
requests==2.31.0
self==2020.12.3
six==1.16.0
slack-sdk==3.26.1
slack-sdk==3.24.0
soupsieve==2.5
sqlparse==0.4.4
tzdata==2023.3
Expand Down

0 comments on commit 0759247

Please sign in to comment.