Skip to content

Commit

Permalink
Reload every hour, rather then every 2 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Jun 21, 2024
1 parent 46e1b06 commit ed0008e
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions eea/climateadapt/browser/countries.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def get_nap_nas(obj, text, country):
children = list(cells[2])

text = [lxml.etree.tostring(c) for c in children]
value = "\n".join(text)
value = unicode("\n").join(text)
key = normalized(key)

if key is None:
Expand All @@ -248,7 +248,7 @@ def get_nap_nas(obj, text, country):
is_nas_country = country in _COUNTRIES_WITH_NAS

if (not value) and (is_nap_country or is_nas_country):
value = "<p>Established</p>"
value = unicode("<p>Established</p>")

if "NAP" in key:
prop = "nap_info"
Expand Down Expand Up @@ -346,17 +346,19 @@ def extract_country_metadata_discodata(self, obj):
value = ""
values = processed_data["Legal_Policies"].get(name, [])

is_nap_country = country_name in _COUNTRIES_WITH_NAP
is_nas_country = country_name in _COUNTRIES_WITH_NAS
# is_nap_country = country_name in _COUNTRIES_WITH_NAP
# is_nas_country = country_name in _COUNTRIES_WITH_NAS

# if (not values) and (is_nap_country or is_nas_country):
# value = u"<p>Established</p>"

if values:
if name == "SAP":
value = [
"<li><a href='{0}'>{1}</a><p {5}>{3}</p>"
"<p {4}>{2}</p></li>".format(
unicode(
"<li><a href='{0}'>{1}</a><p {5}>{3}</p>"
"<p {4}>{2}</p></li>"
).format(
v.get("Link"),
v.get("Title"),
v.get("Status"),
Expand All @@ -368,15 +370,15 @@ def extract_country_metadata_discodata(self, obj):
]
else:
value = [
"<li><a href='{}'>{}</a><p {}>{}</p></li>".format(
unicode("<li><a href='{}'>{}</a><p {}>{}</p></li>").format(
v.get("Link"),
v.get("Title"),
"style='font-style:oblique;'",
v.get("Status"),
)
for v in values
]
value = "<ul>{}</ul>".format("".join(value))
value = unicode("<ul>{}</ul>").format("".join(value))

prop = "{}_info".format(name.lower())

Expand All @@ -400,7 +402,7 @@ def extract_country_metadata_discodata(self, obj):
for key in _response:
data = _response[key]
_value = [
"<li><a href='{}'>{}</a><p {}>{}</p></li>".format(
unicode("<li><a href='{}'>{}</a><p {}>{}</p></li>").format(
v.get("Link"),
v["Title"].encode("ascii", "ignore").decode("ascii"),
"style='font-style:oblique;'",
Expand All @@ -409,8 +411,9 @@ def extract_country_metadata_discodata(self, obj):
for v in data
]
if len(_value):
value += "<span>" + key + "</span>"
value += "<ul>" + "".join(_value) + "</ul>"
value += unicode("<span>") + key + unicode("</span>")
value += unicode("<ul>") + \
unicode("").join(_value) + unicode("</ul>")
res["mixed"] = value

# import pdb; pdb.set_trace()
Expand All @@ -426,8 +429,10 @@ def extract_country_metadata_discodata(self, obj):

if name == "SAP":
value = [
"<li><a href='{0}'>{1}</a><p {5}>{3}</p>"
"<p {4}>{2}</p></li>".format(
unicode(
"<li><a href='{0}'>{1}</a><p {5}>{3}</p>"
"<p {4}>{2}</p></li>"
).format(
v.get("Link"),
v.get("Title"),
v.get("Status"),
Expand All @@ -439,7 +444,7 @@ def extract_country_metadata_discodata(self, obj):
]
else:
value = [
"<li><a href='{}'>{}</a><p {}>{}</p></li>".format(
unicode("<li><a href='{}'>{}</a><p {}>{}</p></li>").format(
v.get("Link"),
v.get("Title"),
"style='font-style:oblique;'",
Expand All @@ -448,7 +453,7 @@ def extract_country_metadata_discodata(self, obj):
for v in data
]
if len(value):
value = "<ul>{}</ul>".format("".join(value))
value = unicode("<ul>{}</ul>").format("".join(value))
else:
value = ""

Expand All @@ -461,7 +466,7 @@ def extract_country_metadata_discodata(self, obj):
values = processed_data["National_Circumstances"].get("CC_IVA", [])
if values:
value = [
"<li><a href='{}'>{}</a><p {}>{}</p></li>".format(
unicode("<li><a href='{}'>{}</a><p {}>{}</p></li>").format(
v.get("Link"),
v.get("Title"),
"style='font-style:oblique;'",
Expand All @@ -482,7 +487,9 @@ def extract_country_metadata_discodata(self, obj):

if values:
value = [
"<li><a href='{0}'>{1}</a><p {5}>{3}</p>" "<p {4}>{2}</p></li>".format(
unicode(
"<li><a href='{0}'>{1}</a><p {5}>{3}</p>" "<p {4}>{2}</p></li>"
).format(
v.get("Website"),
v.get("Name"),
v.get("Status"),
Expand All @@ -492,7 +499,7 @@ def extract_country_metadata_discodata(self, obj):
)
for v in values
]
value = "<ul>{}</ul>".format("".join(value))
value = unicode("<ul>{}</ul>").format("".join(value))

focus_vals = [
f for focus in values for f in focus.get("Focus", "").split("; ")
Expand Down Expand Up @@ -621,7 +628,7 @@ def __call__(self):
key = "".join(cells[0].itertext()).strip()
children = list(cells[2])
text = [lxml.etree.tostring(c) for c in children]
value = "\n".join(text)
value = unicode("\n").join(text)
res[key] = value

self.request.response.setHeader("Content-type", "application/json")
Expand Down

0 comments on commit ed0008e

Please sign in to comment.