Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85575e9f9f | ||
|
|
59cd0035fa | ||
|
|
1bf2ed0fd2 | ||
|
|
368762d453 |
No files matched your search
@@ -42,12 +42,12 @@ class PostCRUD:
|
||||
return result.scalar()
|
||||
|
||||
async def due_for_mail(self, cdb: AsyncSession, status: int, today, limit: int):
|
||||
"""배정일이 오늘까지 온 것 중 업장당 1건만, 이른 날짜순."""
|
||||
"""배정일이 오늘인 것만, 업장당 1건."""
|
||||
result = await cdb.execute(
|
||||
select(place_posts)
|
||||
.where(
|
||||
place_posts.status == status, place_posts.deleted == False, # noqa: E712
|
||||
place_posts.scheduled_date <= today,
|
||||
place_posts.scheduled_date == today,
|
||||
)
|
||||
.distinct(place_posts.place_id)
|
||||
.order_by(place_posts.place_id, place_posts.scheduled_date)
|
||||
@@ -62,9 +62,9 @@ class PostCRUD:
|
||||
.where(
|
||||
place_posts.place_id == place_id, place_posts.status == status,
|
||||
place_posts.deleted == False, # noqa: E712
|
||||
place_posts.scheduled_date <= today,
|
||||
place_posts.scheduled_date == today,
|
||||
)
|
||||
.order_by(place_posts.scheduled_date)
|
||||
.order_by(place_posts.created_at)
|
||||
.limit(1)
|
||||
)
|
||||
return result.scalars().first()
|
||||
|
||||
@@ -1275,3 +1275,31 @@ async def test_send_now_mail_failure_alerts_once_and_recovers(client, db_engine,
|
||||
outcome["ok"] = True
|
||||
assert (await client.post(f"/v1/place/{place_id}/post/send-now", headers=h)).json()["result"]["success"] is True
|
||||
assert await kinds() == [("blog_send_failed", True), ("recovery", False)]
|
||||
|
||||
|
||||
async def test_mail_goes_only_for_todays_post_not_backlog(client, db_engine, auth_headers, monkeypatch):
|
||||
from services import blog_jobs, mail_service
|
||||
|
||||
monkeypatch.setattr(mail_service, "is_configured", lambda: True)
|
||||
sent_calls = []
|
||||
monkeypatch.setattr(mail_service, "send", lambda **kwargs: sent_calls.append(kwargs) or True)
|
||||
|
||||
h = await auth_headers("bloggen-today")
|
||||
place_id = await _place(client, h, name="오늘글펜션")
|
||||
async with db_engine.begin() as conn:
|
||||
await conn.execute(
|
||||
text("INSERT INTO sites (site_id, place_id, domain, status) VALUES (:sid, :pid, :dom, :st)"),
|
||||
{"sid": uuid.uuid4(), "pid": place_id, "dom": f"blog-test-{uuid.uuid4().hex[:8]}", "st": SiteStatus.PUBLISHED.value},
|
||||
)
|
||||
await conn.execute(text("UPDATE users SET email = :e WHERE id = :id"), {"e": "today@example.com", "id": "bloggen-today"})
|
||||
old_post = await _seed_post(db_engine, place_id, scheduled=date.today() - timedelta(days=8))
|
||||
today_post = await _seed_post(db_engine, place_id, scheduled=date.today())
|
||||
|
||||
res = await client.post(f"/v1/place/{place_id}/post/send-now", headers=h)
|
||||
assert res.json()["result"]["success"] is True
|
||||
assert await _status(db_engine, today_post) == PostStatus.SENT.value
|
||||
assert await _status(db_engine, old_post) == PostStatus.REVIEWED.value
|
||||
|
||||
assert await blog_jobs.send_reviewed() == 0
|
||||
assert await _status(db_engine, old_post) == PostStatus.REVIEWED.value
|
||||
assert len(sent_calls) == 1
|
||||
@@ -5,21 +5,7 @@ import {isoDate} from '@site/lib/format';
|
||||
import {Carousel, CarouselSlide, Modal, Section} from '@site/lib/ui';
|
||||
|
||||
/** 미니 블로그 — 사장님이 승인한 짧은 글. */
|
||||
type Season = 'spr' | 'sum' | 'aut' | 'win';
|
||||
|
||||
const SEASON_COLOR: Record<Season, string> = {
|
||||
spr: '#4f7942',
|
||||
sum: '#c9820a',
|
||||
aut: '#bf2f1b',
|
||||
win: '#3b6ea5',
|
||||
};
|
||||
|
||||
function seasonOf(month: number): Season {
|
||||
if (month >= 3 && month <= 5) return 'spr';
|
||||
if (month >= 6 && month <= 8) return 'sum';
|
||||
if (month >= 9 && month <= 11) return 'aut';
|
||||
return 'win';
|
||||
}
|
||||
const AUTOPLAY_MS = 7000;
|
||||
|
||||
/** ISO → 한국 시간 기준 월·일·요일. */
|
||||
function kstDateParts(iso: string) {
|
||||
@@ -46,9 +32,9 @@ export function BlogSection() {
|
||||
title="미니 블로그"
|
||||
lead="사장님이 남기는 숙소 이야기입니다."
|
||||
>
|
||||
<Carousel label={`${payload.place.name} 미니 블로그`} align="start" gap={0.875} loop>
|
||||
<Carousel label={`${payload.place.name} 미니 블로그`} align="start" gap={0.875} loop autoplay={AUTOPLAY_MS}>
|
||||
{posts.map((post) => (
|
||||
<CarouselSlide key={post.postId} basis="basis-[225px]">
|
||||
<CarouselSlide key={post.postId} basis="basis-[272px]">
|
||||
<PostCard post={post} onOpen={() => setOpenId(post.postId)} />
|
||||
</CarouselSlide>
|
||||
))}
|
||||
@@ -65,21 +51,29 @@ export function BlogSection() {
|
||||
|
||||
function PostCard({post, onOpen}: {post: PostEntry; onOpen: () => void}) {
|
||||
const {month, day, weekday} = kstDateParts(post.publishedAt);
|
||||
const season = seasonOf(month);
|
||||
const color = SEASON_COLOR[season];
|
||||
const dateLabel = `${month}월 ${day}일 · ${weekday}`;
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onOpen}
|
||||
className="panel flex aspect-square w-full flex-col gap-2 p-4 text-left"
|
||||
style={{backgroundColor: `color-mix(in srgb, ${color} 9%, var(--tpl-card, #efe7d3))`}}
|
||||
aria-label={`${month}월 ${day}일 ${weekday} 글 열기`}
|
||||
className="panel flex h-full min-h-[17rem] w-full flex-col p-5 text-left"
|
||||
style={{backgroundColor: 'var(--tpl-card)'}}
|
||||
>
|
||||
<time dateTime={post.publishedAt} className="block shrink-0 text-[length:var(--fs-xs)] font-bold tracking-wide" style={{color}}>
|
||||
{dateLabel}
|
||||
<time dateTime={post.publishedAt} className="flex shrink-0 items-center gap-3">
|
||||
<span
|
||||
className="text-[2.75rem] leading-none tabular-nums"
|
||||
style={{color: 'var(--tpl-primary)', fontFamily: 'var(--tpl-font-heading)', fontWeight: 'var(--tpl-heading-weight, 700)'}}
|
||||
>
|
||||
{day}
|
||||
</span>
|
||||
<span className="flex flex-col text-[length:var(--fs-xs)] leading-snug opacity-75">
|
||||
<span>{month}월</span>
|
||||
<span>{weekday}</span>
|
||||
</span>
|
||||
</time>
|
||||
<p className="line-clamp-5 min-h-0 flex-1 whitespace-pre-line break-keep text-[length:var(--fs-xs)] leading-relaxed">
|
||||
<span aria-hidden className="my-4 block h-px w-full shrink-0" style={{backgroundColor: 'var(--tpl-border, currentColor)', opacity: 0.6}} />
|
||||
<p className="line-clamp-4 min-h-0 whitespace-pre-line break-keep text-[length:var(--fs-body)] leading-relaxed">
|
||||
{post.body}
|
||||
</p>
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user