remove nginx

This commit is contained in:
2026-04-10 00:25:43 +02:00
parent 9223e4d35f
commit 94527be868
16 changed files with 259 additions and 126 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
name = "astronome"
version = "0.1.0"
edition = "2021"
edition = "2024"
[[bin]]
name = "astronome"
+11 -14
View File
@@ -1,21 +1,18 @@
FROM rust:latest AS builder
FROM rust:1.93.0-slim AS builder
WORKDIR /app
ENV CARGO_HOME=/usr/local/cargo
ENV CARGO_TARGET_DIR=/app/target
RUN apt-get update && apt-get install -y pkg-config libssl-dev
RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
COPY Cargo.toml ./
# clean build (important)
RUN cargo clean || true
# Create dummy main to cache dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release
RUN rm -rf src
COPY src ./src
# Force rebuild of main crate
RUN touch src/main.rs && cargo build --release
RUN cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y libssl3 ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN mkdir -p /data/gallery
COPY --from=builder /app/target/release/astronome /usr/local/bin/
CMD ["astronome"]
+1 -1
View File
@@ -1,5 +1,5 @@
use axum::{extract::State, Json};
use chrono::{NaiveDateTime, Utc};
use chrono::NaiveDateTime;
use super::{AppError, AppState};
+1 -2
View File
@@ -5,8 +5,7 @@ pub mod solar;
pub mod time;
pub mod visibility;
pub use coords::{airmass, extinction_mag, radec_to_altaz};
pub use horizon::{horizon_alt, HorizonPoint};
pub use horizon::HorizonPoint;
pub use lunar::{moon_age_days, moon_altitude, moon_illumination, moon_phase_name, moon_position, moon_rise_set, moon_separation};
pub use solar::astro_twilight;
pub use time::julian_date;
+2 -2
View File
@@ -110,8 +110,8 @@ pub fn normalize_catalog_id(raw: &str) -> String {
pub fn is_suitable(row: &RawCatalogRow) -> bool {
// Validate RA/Dec exist — required for all objects
let Some(ra) = row.ra_deg() else { return false };
let Some(dec) = row.dec_deg() else { return false };
let Some(_ra) = row.ra_deg() else { return false };
let Some(_dec) = row.dec_deg() else { return false };
// Declination constraint: 30° ≤ Dec ≤ +75° (spec §5.2)
// if dec < -30.0 || dec > 75.0 {
+1 -1
View File
@@ -55,7 +55,7 @@ fn parse_vizier_tsv(text: &str) -> Vec<VdbRow> {
let mut header: Vec<String> = Vec::new();
let mut found_separator = false;
for (line_num, line) in text.lines().enumerate() {
for (_line_num, line) in text.lines().enumerate() {
// Skip comment/meta lines
if line.starts_with('#') {
continue;
+1 -1
View File
@@ -37,7 +37,7 @@ async fn main() -> anyhow::Result<()> {
let app = api::build_router(pool).layer(cors);
let bind_addr = "0.0.0.0:3301";
let bind_addr = "0.0.0.0:3001";
tracing::info!("Starting server on {}", bind_addr);
let listener = tokio::net::TcpListener::bind(bind_addr).await?;
+75 -5
View File
@@ -181,11 +181,16 @@ pub fn parse_phd2_log(content: &str) -> anyhow::Result<Phd2Analysis> {
snr_vals.iter().sum::<f64>() / snr_vals.len() as f64
};
let duration_sec = match (first_time, last_time) {
(Some(f), Some(l)) => (l - f).max(0.0),
_ => 0.0,
};
let duration_min = (duration_sec / 60.0) as u32;
// Try to extract duration from guiding session timestamps first
// If not available, fall back to CSV time span
let duration_min = extract_guiding_duration(content)
.unwrap_or_else(|| {
let duration_sec = match (first_time, last_time) {
(Some(f), Some(l)) => (l - f).max(0.0),
_ => 0.0,
};
(duration_sec / 60.0) as u32
});
// Simple linear drift: last half minus first half average
let drift_ra = if n > 4.0 {
@@ -304,3 +309,68 @@ fn extract_date_from_timestamp(timestamp: &str) -> Option<String> {
}
None
}
fn extract_guiding_duration(content: &str) -> Option<u32> {
// Find first "Guiding Begins at YYYY-MM-DD HH:MM:SS"
// Find last "Guiding Ends at YYYY-MM-DD HH:MM:SS"
// Calculate duration from the time span
let mut begins_timestamp: Option<&str> = None;
let mut ends_timestamp: Option<&str> = None;
for line in content.lines() {
if line.contains("Guiding Begins at ") && begins_timestamp.is_none() {
if let Some(idx) = line.find("Guiding Begins at ") {
let ts = &line[idx + 18..];
// Take first 19 chars: YYYY-MM-DD HH:MM:SS
if ts.len() >= 19 {
begins_timestamp = Some(&ts[..19]);
}
}
}
if line.contains("Guiding Ends at ") {
if let Some(idx) = line.find("Guiding Ends at ") {
let ts = &line[idx + 16..];
// Take first 19 chars: YYYY-MM-DD HH:MM:SS
if ts.len() >= 19 {
ends_timestamp = Some(&ts[..19]);
}
}
}
}
// If we have both timestamps, calculate duration
if let (Some(begin), Some(end)) = (begins_timestamp, ends_timestamp) {
// Parse timestamps like "2026-03-17 20:04:53"
if let (Some(begin_dt), Some(end_dt)) = (parse_phd2_timestamp(begin), parse_phd2_timestamp(end)) {
let duration_secs = (end_dt - begin_dt).max(0.0);
return Some((duration_secs / 60.0) as u32);
}
}
None
}
fn parse_phd2_timestamp(timestamp: &str) -> Option<f64> {
// Parse timestamp like "2026-03-17 20:04:53" to Unix seconds (or any consistent float)
// We just need the relative difference, so we can use a simple approach:
// Convert to total seconds for the day
if timestamp.len() < 19 {
return None;
}
let year: u32 = timestamp[..4].parse().ok()?;
let month: u32 = timestamp[5..7].parse().ok()?;
let day: u32 = timestamp[8..10].parse().ok()?;
let hour: u32 = timestamp[11..13].parse().ok()?;
let min: u32 = timestamp[14..16].parse().ok()?;
let sec: u32 = timestamp[17..19].parse().ok()?;
// Use chrono to parse it properly
use chrono::NaiveDate;
let naive_date = NaiveDate::from_ymd_opt(year as i32, month, day)?;
let naive_time = chrono::NaiveTime::from_hms_opt(hour, min, sec)?;
let naive_dt = chrono::NaiveDateTime::new(naive_date, naive_time);
Some(naive_dt.and_utc().timestamp() as f64)
}