Skip re-downloading site MP3s; reuse existing Gooya audio on PVC.
build-and-deploy / deploy (push) Successful in 2m34s
build-and-deploy / deploy (push) Successful in 2m34s
Crawl only ayah text/notes/messages; API falls back to episode audio.
This commit is contained in:
@@ -97,18 +97,26 @@ public static class TafsirEndpoints
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
var episodeAyahs = (await db.Episodes.AsNoTracking()
|
||||
.Where(e => e.TafsirId == tafsir.Id && e.SurahId == surah.Id)
|
||||
.Select(e => e.AyahNumber)
|
||||
.Distinct()
|
||||
.ToListAsync(ct)).ToHashSet();
|
||||
|
||||
var list = ayahs.Select(a =>
|
||||
{
|
||||
contents.TryGetValue(a.Number, out var c);
|
||||
var preview = a.TextFa;
|
||||
if (!string.IsNullOrWhiteSpace(preview) && preview.Length > 80)
|
||||
preview = preview[..80] + "…";
|
||||
var hasAudio = !string.IsNullOrWhiteSpace(c?.AudioPath) || episodeAyahs.Contains(a.Number)
|
||||
|| episodeAyahs.Count > 0;
|
||||
return new AyahListItemDto(
|
||||
surah.Number,
|
||||
surah.NameFa,
|
||||
a.Number,
|
||||
preview,
|
||||
!string.IsNullOrWhiteSpace(c?.AudioPath),
|
||||
hasAudio,
|
||||
bookmarks.Contains(a.Number),
|
||||
favorites.Contains(a.Number));
|
||||
}).ToList();
|
||||
@@ -156,7 +164,24 @@ public static class TafsirEndpoints
|
||||
|
||||
string? audioUrl = null;
|
||||
if (!string.IsNullOrWhiteSpace(content?.AudioPath))
|
||||
{
|
||||
audioUrl = $"/api/audio/ayah/{surahNumber}/{ayahNumber}?tafsirId={tafsir.Id}";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fall back to existing Gooya episode audio already on PVC (best-effort ayah match).
|
||||
var episode = await db.Episodes.AsNoTracking()
|
||||
.Where(e => e.TafsirId == tafsir.Id && e.SurahId == surah.Id && e.AyahNumber == ayahNumber)
|
||||
.OrderBy(e => e.SortOrder)
|
||||
.FirstOrDefaultAsync(ct);
|
||||
episode ??= await db.Episodes.AsNoTracking()
|
||||
.Where(e => e.TafsirId == tafsir.Id && e.SurahId == surah.Id)
|
||||
.OrderBy(e => Math.Abs(e.AyahNumber - ayahNumber))
|
||||
.ThenBy(e => e.SortOrder)
|
||||
.FirstOrDefaultAsync(ct);
|
||||
if (episode is not null)
|
||||
audioUrl = $"/api/audio/{episode.Id}";
|
||||
}
|
||||
|
||||
return Results.Ok(new AyahDetailDto(
|
||||
tafsir.Id,
|
||||
|
||||
Reference in New Issue
Block a user