krz/moonrise

Night-sky companion for iPhone, Apple Watch and Vision Pro: what's up tonight, the Moon, planets, launches and missions, and a Library of the solar system. SwiftUI app with a Cloudflare Workers backend. astronomy cloudflare-workers ios night-sky space swiftui visionos watchos

Commit a1c0bd8138

a1c0bd81382e413f2c7549ebe65c94977655398a

parent: c5f57d4e01

Unsigned

cmc <hello@cleberg.net> · 2026-10-23 06:54 UTC

Space Devs terms: hourly SNAPI poll, linked credits (!149)

- Poll the Spaceflight News API at the top of each hour, as The Space Devs asked; the 10-minute cron still sends digests.
- Credits rows for Launch Library 2 and the Spaceflight News API link to thespacedevs.com.
- App Store description gains a DATA section crediting both (3,761 of 4,000 characters).

Server tests 84/84; app builds for the simulator.

Layout: unified · split

App/AppStore/metadata.md +3
@@ -60,6 +60,9 @@ AND MORE
60- Control Center controls for the Sky, Sun and Launches tabs 60- Control Center controls for the Sky, Sun and Launches tabs
61- An Apple Watch app and complications 61- An Apple Watch app and complications
62 62
63DATA
64Launch data from Launch Library 2 and news headlines from the Spaceflight News API, both by The Space Devs (thespacedevs.com).
65
63## Keywords 66## Keywords
64 67
65astronomy,stars,planets,moon phase,constellations,star chart,stargazing,nasa,launch,aurora,eclipse 68astronomy,stars,planets,moon phase,constellations,star chart,stargazing,nasa,launch,aurora,eclipse
App/Sources/SettingsScreen.swift +6 −3
@@ -259,6 +259,7 @@ struct CreditsScreen: View {
259 private struct Credit: Hashable { 259 private struct Credit: Hashable {
260 var name: String 260 var name: String
261 var detail: String 261 var detail: String
262 var url: URL? = nil
262 } 263 }
263 264
264 private let software: [Credit] = [ 265 private let software: [Credit] = [
@@ -273,11 +274,11 @@ struct CreditsScreen: View {
273 private let feeds: [Credit] = [ 274 private let feeds: [Credit] = [
274 Credit(name: "Space weather and aurora forecast", detail: "NOAA Space Weather Prediction Center."), 275 Credit(name: "Space weather and aurora forecast", detail: "NOAA Space Weather Prediction Center."),
275 Credit(name: "Images of the Sun", detail: "Courtesy of NASA/SDO and the AIA, EVE, and HMI science teams."), 276 Credit(name: "Images of the Sun", detail: "Courtesy of NASA/SDO and the AIA, EVE, and HMI science teams."),
276 Credit(name: "Launch schedule", detail: "The Space Devs, Launch Library 2."), 277 Credit(name: "Launch schedule", detail: "The Space Devs, Launch Library 2.", url: URL(string: "https://thespacedevs.com")),
277 Credit(name: "Deep Space Network status", detail: "NASA/JPL, DSN Now."), 278 Credit(name: "Deep Space Network status", detail: "NASA/JPL, DSN Now."),
278 Credit(name: "Satellite orbits", detail: "CelesTrak."), 279 Credit(name: "Satellite orbits", detail: "CelesTrak."),
279 Credit(name: "Mars rover raw images", detail: "NASA/JPL-Caltech, with MSSS and ASU for some cameras."), 280 Credit(name: "Mars rover raw images", detail: "NASA/JPL-Caltech, with MSSS and ASU for some cameras."),
280 Credit(name: "Space news headlines", detail: "Spaceflight News API, The Space Devs. Articles belong to their publishers."), 281 Credit(name: "Space news headlines", detail: "Spaceflight News API, The Space Devs. Articles belong to their publishers.", url: URL(string: "https://thespacedevs.com")),
281 ] 282 ]
282 283
283 /// Every distinct image credit used by the Library, grouped by licence. 284 /// Every distinct image credit used by the Library, grouped by licence.
@@ -320,11 +321,13 @@ struct CreditsScreen: View {
320 .navigationTitle("Credits and licences") 321 .navigationTitle("Credits and licences")
321 } 322 }
322 323
324 @ViewBuilder
323 private func row(_ c: Credit) -> some View { 325 private func row(_ c: Credit) -> some View {
324 VStack(alignment: .leading, spacing: 2) { 326 let text = VStack(alignment: .leading, spacing: 2) {
325 Text(c.name) 327 Text(c.name)
326 Text(c.detail).font(.footnote).foregroundStyle(.secondary) 328 Text(c.detail).font(.footnote).foregroundStyle(.secondary)
327 } 329 }
330 if let url = c.url { Link(destination: url) { text } } else { text }
328 } 331 }
329} 332}
330 333
server/src/index.ts +2 −2
@@ -210,7 +210,7 @@ export default {
210 async scheduled(controller: ScheduledController, env: Env, ctx: ExecutionContext): Promise<void> { 210 async scheduled(controller: ScheduledController, env: Env, ctx: ExecutionContext): Promise<void> {
211 const now = new Date(controller.scheduledTime); 211 const now = new Date(controller.scheduledTime);
212 if (controller.cron === NEWS_CRON) { 212 if (controller.cron === NEWS_CRON) {
213 ctx.waitUntil(pollNews(env, now).then(() => sendNewsDigests(env, now))); 213 ctx.waitUntil((now.getUTCMinutes() === 0 ? pollNews(env, now) : Promise.resolve()).then(() => sendNewsDigests(env, now)));
214 if (now.getUTCHours() === 0 && now.getUTCMinutes() === 0) ctx.waitUntil(prune(env, now)); 214 if (now.getUTCHours() === 0 && now.getUTCMinutes() === 0) ctx.waitUntil(prune(env, now));
215 } else if (controller.cron === SATELLITE_CRON) ctx.waitUntil(pollSatellites(env, now)); 215 } else if (controller.cron === SATELLITE_CRON) ctx.waitUntil(pollSatellites(env, now));
216 else if (controller.cron === FOCUS_CRON) ctx.waitUntil(focusTick(env, now)); 216 else if (controller.cron === FOCUS_CRON) ctx.waitUntil(focusTick(env, now));
@@ -760,7 +760,7 @@ async function sendAuroraAlerts(env: Env, w: SpaceWeather, wind: SolarWind | nul
760 })); 760 }));
761} 761}
762 762
763/** Spaceflight News API every 10 minutes, matching its cache lifetime; the last good copy is kept on failure. */ 763/** Spaceflight News API hourly, as The Space Devs asked; the last good copy is kept on failure. */
764async function pollNews(env: Env, now: Date): Promise<void> { 764async function pollNews(env: Env, now: Date): Promise<void> {
765 try { 765 try {
766 const articles = await fetchLatest(); 766 const articles = await fetchLatest();
server/src/news.ts +1 −1
@@ -1,4 +1,4 @@
1// Spaceflight News API (The Space Devs). Free, no key. Polled every 10 minutes for /v1/news and the daily digest push. 1// Spaceflight News API (The Space Devs). Free, no key. Polled hourly for /v1/news and the daily digest push.
2import { USER_AGENT } from "./agent.ts"; 2import { USER_AGENT } from "./agent.ts";
3 3
4export interface Article { 4export interface Article {
server/test/worker.test.ts +2 −2
@@ -212,7 +212,7 @@ test("an LL2 429 stops LL2 requests until /api-throttle/ says the limit has rese
212 assert.equal(paths.length, 3); 212 assert.equal(paths.length, 3);
213}); 213});
214 214
215test("/v1/news serves the articles the 10-minute cron stored", async () => { 215test("/v1/news serves the articles the hourly poll stored", async () => {
216 const { env } = await setup({ APNS_KEY: "" }); 216 const { env } = await setup({ APNS_KEY: "" });
217 const article = { id: 7, title: "t", summary: "s", url: "https://example.com/a", image_url: null, news_site: "ESA", published_at: "2026-10-20T13:00:00Z", authors: [] }; 217 const article = { id: 7, title: "t", summary: "s", url: "https://example.com/a", image_url: null, news_site: "ESA", published_at: "2026-10-20T13:00:00Z", authors: [] };
218 network({ "api.spaceflightnewsapi.net": () => Response.json({ results: [article] }) }); 218 network({ "api.spaceflightnewsapi.net": () => Response.json({ results: [article] }) });
@@ -305,7 +305,7 @@ test("news digests go out in slices during the local 09:00 hour, once per local
305 assert.equal(new Set(push.state.sent).size, PUSH_SLICE + 5); 305 assert.equal(new Set(push.state.sent).size, PUSH_SLICE + 5);
306 await run(env, NEWS, "2026-10-20T14:20:00Z"); 306 await run(env, NEWS, "2026-10-20T14:20:00Z");
307 assert.equal(push.state.sent.length, PUSH_SLICE + 5); 307 assert.equal(push.state.sent.length, PUSH_SLICE + 5);
308 assert.equal(snapi(), 3, "polled once per 10-minute run"); 308 assert.equal(snapi(), 1, "polled at the top of the hour only");
309 assert.equal(count(db, "SELECT count(*) AS n FROM alerts_sent WHERE kind = 'news' AND event LIKE '%:2026-10-20'"), PUSH_SLICE + 5); 309 assert.equal(count(db, "SELECT count(*) AS n FROM alerts_sent WHERE kind = 'news' AND event LIKE '%:2026-10-20'"), PUSH_SLICE + 5);
310 310
311 const q = calls.find((c) => c.sql.includes("news = 1"))!; 311 const q = calls.find((c) => c.sql.includes("news = 1"))!;