Skip to content

Commit

Permalink
Add self-reported Overwatcher comments to the night log
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Nov 17, 2024
1 parent 74b1427 commit def6a6d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Next version

### ✨ Improved

* Add self-reported Overwatcher comments to the night log.


## 0.1.15 - 2024-11-12

### 🚀 New
Expand Down
14 changes: 14 additions & 0 deletions src/lvmapi/data/night_log_email_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ <h1 class="header-text">
<div>No comments.</div>
{% endif %}

<div class="section">
Overwatcher self-reported comments
</div>
<hr />
{% if overwatcher %}
<ul>
{% for comment in overwatcher %}
<li>{{ comment.comment }}</li>
{% endfor %}
</ul>
{% else %}
<div>No comments.</div>
{% endif %}

<div class="section">
Night metrics
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/lvmapi/routers/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class NightLogPostComment(BaseModel):
Field(description="The MJD associated with the comment"),
]
category: Annotated[
Literal["weather", "issues", "other", "observers"],
Literal["weather", "issues", "other", "observers", "overwatcher"],
Field(description="The category of the comment"),
]
comment: Annotated[
Expand Down
15 changes: 11 additions & 4 deletions src/lvmapi/tools/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ async def create_night_log_entry(mjd: int | None = None):
return mjd


NightLogCategories = Literal["weather", "issues", "other", "observers"]
NightLogCategories = Literal["weather", "issues", "other", "observers", "overwatcher"]


async def add_night_log_comment(
Expand Down Expand Up @@ -565,6 +565,10 @@ async def get_plaintext_night_log(sjd: int | None = None):
-----
{other}
Overwatcher self-reported
-------------------------
{overwatcher}
Night metrics
-------------
- Night length: {night_length}.
Expand Down Expand Up @@ -593,9 +597,10 @@ async def get_plaintext_night_log(sjd: int | None = None):
observers = data["observers"] or "Overwatcher"

comments = data["comments"]
weather = ["- {}".format(comments["comment"]) for comments in comments["weather"]]
issues = ["- {}".format(comments["comment"]) for comments in comments["issues"]]
other = ["- {}".format(comments["comment"]) for comments in comments["other"]]
weather = ["- {}".format(comms["comment"]) for comms in comments["weather"]]
issues = ["- {}".format(comms["comment"]) for comms in comments["issues"]]
other = ["- {}".format(comms["comment"]) for comms in comments["other"]]
overwatcher = ["- {}".format(comms["comment"]) for comms in comments["overwatcher"]]

exposure_table = await get_exposure_table_ascii(
sjd,
Expand Down Expand Up @@ -644,6 +649,7 @@ async def get_plaintext_night_log(sjd: int | None = None):
weather="\n".join(weather) or "No comments",
issues="\n".join(issues) or "No comments",
other="\n".join(other) or "No comments",
overwatcher="\n".join(overwatcher) or "No comments",
versions="\n".join(versions_l),
exposure_data=exposure_table or "No exposures found",
notifications="\n".join(notifications_to_list(notifications)),
Expand Down Expand Up @@ -728,6 +734,7 @@ async def email_night_log(
weather=data["comments"]["weather"],
issues=data["comments"]["issues"],
other=data["comments"]["other"],
overwatcher=data["comments"]["overwatcher"],
exposure_table=exposure_table.strip() if exposure_table else None,
software_versions=versions,
notifications=("\n".join(notifications_to_list(notifications))).strip(),
Expand Down

0 comments on commit def6a6d

Please sign in to comment.