fix(seed): IgnoreQueryFilters on all seeder queries + sitemap invalid date guard
CI/CD / CI · API (dotnet build + test) (push) Successful in 45s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 31s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m13s
CI/CD / CI · Admin Web (tsc) (push) Successful in 40s
CI/CD / CI · Website (tsc) (push) Successful in 47s
CI/CD / CI · Koja (tsc) (push) Successful in 59s
CI/CD / Deploy · all services (push) Successful in 3m45s

DemoSeedService / DemoMenuSeeder:
  Add IgnoreQueryFilters() to every seeder lookup (Taxes, MenuCategories,
  MenuItems). Soft-deleted rows still hold their PKs; without this a second
  seed run after user-deletion throws a PK collision on the Tax or category
  that was soft-deleted but is still in the index.

sitemap.ts:
  Guard new Date(post.date) against empty / missing frontmatter date fields.
  new Date("") = Invalid Date → broken <lastmod> in sitemap XML.
  Fall back to the build-time date when the post date is absent or invalid.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-20 15:54:07 +03:30
parent 1daa6d452c
commit 73a5e5183b
3 changed files with 9 additions and 3 deletions
+4 -1
View File
@@ -33,7 +33,9 @@ public class DemoSeedService : IDemoSeedService
// 1. Ensure 9% default tax // 1. Ensure 9% default tax
var taxId = $"{cafeId}_demo_tax"; var taxId = $"{cafeId}_demo_tax";
var taxCreated = false; var taxCreated = false;
if (!await _db.Taxes.AnyAsync(t => t.CafeId == cafeId && t.IsDefault, ct)) // IgnoreQueryFilters: soft-deleted rows still occupy the PK; re-seeding
// after a user deletes demo data must see those rows to avoid a PK collision.
if (!await _db.Taxes.IgnoreQueryFilters().AnyAsync(t => t.CafeId == cafeId && t.IsDefault, ct))
{ {
_db.Taxes.Add(new Tax _db.Taxes.Add(new Tax
{ {
@@ -51,6 +53,7 @@ public class DemoSeedService : IDemoSeedService
else else
{ {
taxId = await _db.Taxes taxId = await _db.Taxes
.IgnoreQueryFilters()
.Where(t => t.CafeId == cafeId && t.IsDefault) .Where(t => t.CafeId == cafeId && t.IsDefault)
.Select(t => t.Id) .Select(t => t.Id)
.FirstAsync(ct); .FirstAsync(ct);
@@ -23,7 +23,7 @@ public static class DemoMenuSeeder
string Scoped(string catalogId) => string Scoped(string catalogId) =>
useScopedIds ? $"{cafeId}_{catalogId}" : catalogId; useScopedIds ? $"{cafeId}_{catalogId}" : catalogId;
if (!await db.Taxes.AnyAsync(t => t.Id == taxId && t.CafeId == cafeId)) if (!await db.Taxes.IgnoreQueryFilters().AnyAsync(t => t.Id == taxId && t.CafeId == cafeId))
{ {
db.Taxes.Add(new Tax db.Taxes.Add(new Tax
{ {
@@ -38,6 +38,7 @@ public static class DemoMenuSeeder
} }
var existingCategoryIds = await db.MenuCategories var existingCategoryIds = await db.MenuCategories
.IgnoreQueryFilters()
.Where(c => c.CafeId == cafeId) .Where(c => c.CafeId == cafeId)
.ToDictionaryAsync(c => c.Id, StringComparer.Ordinal); .ToDictionaryAsync(c => c.Id, StringComparer.Ordinal);
@@ -78,6 +79,7 @@ public static class DemoMenuSeeder
} }
var existingItemIds = await db.MenuItems var existingItemIds = await db.MenuItems
.IgnoreQueryFilters()
.Where(i => i.CafeId == cafeId) .Where(i => i.CafeId == cafeId)
.Select(i => i.Id) .Select(i => i.Id)
.ToListAsync(); .ToListAsync();
+2 -1
View File
@@ -42,9 +42,10 @@ export default function sitemap(): MetadataRoute.Sitemap {
const posts = getAllPosts(locale); const posts = getAllPosts(locale);
for (const post of posts) { for (const post of posts) {
const postDate = post.date ? new Date(post.date) : null;
entries.push({ entries.push({
url: `${BASE_URL}/${locale}/blog/${post.slug}`, url: `${BASE_URL}/${locale}/blog/${post.slug}`,
lastModified: new Date(post.date), lastModified: postDate && !isNaN(postDate.getTime()) ? postDate : now,
changeFrequency: "monthly", changeFrequency: "monthly",
priority: 0.7, priority: 0.7,
}); });