Compare commits
No commits in common. "23aa70bb84e0bc8386263e807983a0dc39e4a4cd" and "bd129aea5c59149a62cf5a631aae3fe8d50dca84" have entirely different histories.
23aa70bb84
...
bd129aea5c
|
@ -15,10 +15,8 @@ Summary = dict[str, typing.Any]
|
|||
|
||||
ttl = 60 * 60 * 2 # two hours
|
||||
|
||||
LIMIT = 500
|
||||
|
||||
|
||||
def next_launch_api_data(rocket_dir: str, limit: int = LIMIT) -> StrDict | None:
|
||||
def next_launch_api_data(rocket_dir: str, limit: int = 200) -> StrDict | None:
|
||||
"""Get the next upcoming launches from the API."""
|
||||
now = datetime.now()
|
||||
filename = os.path.join(rocket_dir, now.strftime("%Y-%m-%d_%H:%M:%S.json"))
|
||||
|
@ -34,7 +32,7 @@ def next_launch_api_data(rocket_dir: str, limit: int = LIMIT) -> StrDict | None:
|
|||
return data
|
||||
|
||||
|
||||
def next_launch_api(rocket_dir: str, limit: int = LIMIT) -> list[Summary] | None:
|
||||
def next_launch_api(rocket_dir: str, limit: int = 200) -> list[Summary] | None:
|
||||
"""Get the next upcoming launches from the API."""
|
||||
data = next_launch_api_data(rocket_dir, limit)
|
||||
if not data:
|
||||
|
@ -159,7 +157,7 @@ def read_cached_launches(rocket_dir: str) -> list[Summary]:
|
|||
|
||||
|
||||
def get_launches(
|
||||
rocket_dir: str, limit: int = LIMIT, refresh: bool = False
|
||||
rocket_dir: str, limit: int = 200, refresh: bool = False
|
||||
) -> list[Summary] | None:
|
||||
"""Get rocket launches with caching."""
|
||||
now = datetime.now()
|
||||
|
|
|
@ -39,21 +39,6 @@
|
|||
{% endfor %}
|
||||
</p>
|
||||
|
||||
<p>Orbit:
|
||||
{% if request.args.orbit %}<a href="{{ request.path }}">🗙</a>{% endif %}
|
||||
|
||||
{% for name, abbrev in orbits | sort %}
|
||||
{% if abbrev == request.args.orbit %}
|
||||
<strong>{{ name }}</strong>
|
||||
{% else %}
|
||||
<a href="?orbit={{ abbrev }}" class="text-nowrap">
|
||||
{{ name }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if not loop.last %} | {% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
|
||||
{% for launch in launches %}
|
||||
{% set highlight =" bg-primary-subtle" if launch.slug in config.FOLLOW_LAUNCHES else "" %}
|
||||
{% set country = get_country(launch.country_code) %}
|
||||
|
|
12
web_view.py
12
web_view.py
|
@ -150,21 +150,14 @@ def launch_list() -> str:
|
|||
data_dir = app.config["DATA_DIR"]
|
||||
rocket_dir = os.path.join(data_dir, "thespacedevs")
|
||||
launches = agenda.thespacedevs.get_launches(rocket_dir, limit=100)
|
||||
assert launches
|
||||
|
||||
mission_type_filter = flask.request.args.get("type")
|
||||
rocket_filter = flask.request.args.get("rocket")
|
||||
orbit_filter = flask.request.args.get("orbit")
|
||||
|
||||
mission_types = {
|
||||
launch["mission"]["type"] for launch in launches if launch["mission"]
|
||||
}
|
||||
|
||||
orbits = {
|
||||
(launch["orbit"]["name"], launch["orbit"]["abbrev"])
|
||||
for launch in launches
|
||||
if launch.get("orbit")
|
||||
}
|
||||
rockets = {launch["rocket"]["full_name"] for launch in launches}
|
||||
|
||||
launches = [
|
||||
|
@ -175,10 +168,6 @@ def launch_list() -> str:
|
|||
or (launch["mission"] and launch["mission"]["type"] == mission_type_filter)
|
||||
)
|
||||
and (not rocket_filter or launch["rocket"]["full_name"] == rocket_filter)
|
||||
and (
|
||||
not orbit_filter
|
||||
or (launch.get("orbit") and launch["orbit"]["abbrev"] == orbit_filter)
|
||||
)
|
||||
]
|
||||
|
||||
return flask.render_template(
|
||||
|
@ -188,7 +177,6 @@ def launch_list() -> str:
|
|||
now=now,
|
||||
get_country=agenda.get_country,
|
||||
mission_types=mission_types,
|
||||
orbits=orbits,
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue