Odstranjeni kozmicni dogodki: stran, scheduler in API
This commit is contained in:
parent
b61bfac5d3
commit
7dcee28bf2
@ -26,7 +26,6 @@ import { InArticleAd, PageSideAds } from "@/components/adsense";
|
|||||||
import {
|
import {
|
||||||
SIGNS,
|
SIGNS,
|
||||||
ELEMENT_COLORS,
|
ELEMENT_COLORS,
|
||||||
ASTRO_EVENTS,
|
|
||||||
getHoroscope as getStaticHoroscope,
|
getHoroscope as getStaticHoroscope,
|
||||||
getRating,
|
getRating,
|
||||||
getLuckyNumbers,
|
getLuckyNumbers,
|
||||||
@ -56,88 +55,6 @@ function StarRating({ count }: { count: number }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEventIcon(icon: string) {
|
|
||||||
switch (icon) {
|
|
||||||
case "mercury": return <AlertTriangle className="w-5 h-5 text-amber-400" />;
|
|
||||||
case "moon": return <Moon className="w-5 h-5 text-blue-300" />;
|
|
||||||
case "venus": return <Heart className="w-5 h-5 text-pink-400" />;
|
|
||||||
case "sun": return <Sun className="w-5 h-5 text-amber-300" />;
|
|
||||||
case "saturn": return <Briefcase className="w-5 h-5 text-slate-400" />;
|
|
||||||
case "newmoon": return <Moon className="w-5 h-5 text-violet-400" />;
|
|
||||||
default: return <Star className="w-5 h-5 text-primary" />;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEventColor(type: string) {
|
|
||||||
switch (type) {
|
|
||||||
case "retrograde": return { bg: "bg-amber-500/10", border: "border-amber-500/20", accent: "text-amber-400" };
|
|
||||||
case "moon": return { bg: "bg-blue-500/10", border: "border-blue-500/20", accent: "text-blue-400" };
|
|
||||||
case "transit": return { bg: "bg-pink-500/10", border: "border-pink-500/20", accent: "text-pink-400" };
|
|
||||||
case "season": return { bg: "bg-emerald-500/10", border: "border-emerald-500/20", accent: "text-emerald-400" };
|
|
||||||
default: return { bg: "bg-primary/10", border: "border-primary/20", accent: "text-primary" };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CosmicEvent {
|
|
||||||
title: string;
|
|
||||||
description: string;
|
|
||||||
dateRange: string;
|
|
||||||
icon: string;
|
|
||||||
type: string;
|
|
||||||
affectedSigns: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
function AstroEventsSection() {
|
|
||||||
const { data: apiEvents = [] } = useQuery<CosmicEvent[]>({
|
|
||||||
queryKey: ["/api/cosmic-events"],
|
|
||||||
staleTime: 1000 * 60 * 30,
|
|
||||||
refetchOnWindowFocus: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Use live AI-generated events when available, otherwise fall back to static list.
|
|
||||||
const events = apiEvents.length > 0 ? apiEvents : ASTRO_EVENTS;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="mb-10" data-testid="section-astro-events">
|
|
||||||
<h2 className="text-lg font-bold text-foreground flex items-center gap-2 mb-4">
|
|
||||||
<Sparkles className="w-5 h-5 text-primary" />
|
|
||||||
Aktuelle kosmische Ereignisse
|
|
||||||
</h2>
|
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
||||||
{events.map((event, i) => {
|
|
||||||
const ec = getEventColor(event.type);
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={i}
|
|
||||||
className={`${ec.bg} border ${ec.border} rounded-xl p-4 transition-all hover:scale-[1.02]`}
|
|
||||||
data-testid={`card-astro-event-${i}`}
|
|
||||||
>
|
|
||||||
<div className="flex items-start gap-3 mb-2">
|
|
||||||
{getEventIcon(event.icon)}
|
|
||||||
<div className="flex-1 min-w-0">
|
|
||||||
<h3 className={`font-semibold text-sm ${ec.accent}`}>{event.title}</h3>
|
|
||||||
<p className="text-[11px] text-muted-foreground">{event.dateRange}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p className="text-xs text-foreground/70 leading-relaxed mb-3">{event.description}</p>
|
|
||||||
<div className="flex flex-wrap gap-1">
|
|
||||||
{event.affectedSigns.map((s) => {
|
|
||||||
const sign = SIGNS.find((x) => x.name === s);
|
|
||||||
return (
|
|
||||||
<span key={s} className="text-[10px] bg-white/5 border border-white/10 rounded px-1.5 py-0.5 text-muted-foreground">
|
|
||||||
{sign?.symbol} {s}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function SignGrid({ onSelect, selectedIndex, aiHoroscopes }: { onSelect: (i: number) => void; selectedIndex: number | null; aiHoroscopes: AIHoroscope[] }) {
|
function SignGrid({ onSelect, selectedIndex, aiHoroscopes }: { onSelect: (i: number) => void; selectedIndex: number | null; aiHoroscopes: AIHoroscope[] }) {
|
||||||
return (
|
return (
|
||||||
<section className="mb-10" data-testid="section-sign-grid">
|
<section className="mb-10" data-testid="section-sign-grid">
|
||||||
@ -481,8 +398,6 @@ export default function HoroscopePage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<AstroEventsSection />
|
|
||||||
|
|
||||||
<InArticleAd />
|
<InArticleAd />
|
||||||
|
|
||||||
<SignGrid onSelect={handleSelect} selectedIndex={selected} aiHoroscopes={aiHoroscopes} />
|
<SignGrid onSelect={handleSelect} selectedIndex={selected} aiHoroscopes={aiHoroscopes} />
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { createServer, type Server } from "http";
|
|||||||
import { storage } from "./storage";
|
import { storage } from "./storage";
|
||||||
import { insertArticleSchema } from "@shared/schema";
|
import { insertArticleSchema } from "@shared/schema";
|
||||||
import { seedDatabase } from "./seed";
|
import { seedDatabase } from "./seed";
|
||||||
import { generateDailyHoroscopes, getHoroscopesForToday, getOrGenerateHoroscope, getCosmicEventsForToday, generateCosmicEvents, setHoroscopeImages } from "./horoscope-generator";
|
import { generateDailyHoroscopes, getHoroscopesForToday, getOrGenerateHoroscope, setHoroscopeImages } from "./horoscope-generator";
|
||||||
import { startDailyScheduler } from "./scheduler";
|
import { startDailyScheduler } from "./scheduler";
|
||||||
import { analyzeAllArticleImages, getCachedFocalPoints } from "./focal-point";
|
import { analyzeAllArticleImages, getCachedFocalPoints } from "./focal-point";
|
||||||
import { optimizeImage } from "./image-optimizer";
|
import { optimizeImage } from "./image-optimizer";
|
||||||
@ -786,26 +786,6 @@ export async function registerRoutes(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Cosmic events API
|
|
||||||
app.get("/api/cosmic-events", async (_req, res) => {
|
|
||||||
try {
|
|
||||||
const events = await getCosmicEventsForToday();
|
|
||||||
res.json(events);
|
|
||||||
} catch (err: any) {
|
|
||||||
res.status(500).json({ message: err.message });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
app.post("/api/cosmic-events/generate", async (_req, res) => {
|
|
||||||
try {
|
|
||||||
await generateCosmicEvents();
|
|
||||||
const events = await getCosmicEventsForToday();
|
|
||||||
res.json({ generated: events.length, events });
|
|
||||||
} catch (err: any) {
|
|
||||||
res.status(500).json({ message: err.message });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function parseRssItems(xml: string, maxAgeDays?: number): { title: string; link: string; source: string; pubDate: string }[] {
|
function parseRssItems(xml: string, maxAgeDays?: number): { title: string; link: string; source: string; pubDate: string }[] {
|
||||||
const channelTitle = xml.match(/<channel>[\s\S]*?<title>(.*?)<\/title>/)?.[1]?.replace(/<!\[CDATA\[|\]\]>/g, "").trim() || "";
|
const channelTitle = xml.match(/<channel>[\s\S]*?<title>(.*?)<\/title>/)?.[1]?.replace(/<!\[CDATA\[|\]\]>/g, "").trim() || "";
|
||||||
const items: { title: string; link: string; source: string; pubDate: string }[] = [];
|
const items: { title: string; link: string; source: string; pubDate: string }[] = [];
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { generateDailyHoroscopes, generateCosmicEvents } from "./horoscope-generator";
|
import { generateDailyHoroscopes } from "./horoscope-generator";
|
||||||
|
|
||||||
async function runDailyGeneration() {
|
async function runDailyGeneration() {
|
||||||
try {
|
try {
|
||||||
@ -6,11 +6,6 @@ async function runDailyGeneration() {
|
|||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.error("[scheduler] Horoscope generation failed:", err.message);
|
console.error("[scheduler] Horoscope generation failed:", err.message);
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
await generateCosmicEvents();
|
|
||||||
} catch (err: any) {
|
|
||||||
console.error("[scheduler] Cosmic events generation failed:", err.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function startDailyScheduler() {
|
export function startDailyScheduler() {
|
||||||
@ -24,5 +19,5 @@ export function startDailyScheduler() {
|
|||||||
runDailyGeneration();
|
runDailyGeneration();
|
||||||
}, SIX_HOURS);
|
}, SIX_HOURS);
|
||||||
|
|
||||||
console.log("[scheduler] Daily horoscope + cosmic events scheduler started.");
|
console.log("[scheduler] Daily horoscope scheduler started.");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user