Skip to content

Commit 3cf2b30

Browse files
authored
Merge pull request #116 from ThriveCommunityChurch/dev
Adds transcript data model and parsing
2 parents 95643a9 + 873ee6a commit 3cf2b30

2 files changed

Lines changed: 44 additions & 14 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Newtonsoft.Json;
2+
3+
namespace ThriveChurchOfficialAPI.Core
4+
{
5+
/// <summary>
6+
/// DTO for deserializing transcript JSON from Azure Blob Storage.
7+
/// Maps the camelCase blob schema to C# properties.
8+
/// This is an internal blob format - use TranscriptResponse for API responses.
9+
/// </summary>
10+
public class TranscriptBlob
11+
{
12+
[JsonProperty("messageId")]
13+
public string MessageId { get; set; }
14+
15+
[JsonProperty("title")]
16+
public string Title { get; set; }
17+
18+
[JsonProperty("speaker")]
19+
public string Speaker { get; set; }
20+
21+
[JsonProperty("transcript")]
22+
public string Transcript { get; set; }
23+
24+
[JsonProperty("wordCount")]
25+
public int WordCount { get; set; }
26+
27+
[JsonProperty("uploadedAt")]
28+
public string UploadedAt { get; set; }
29+
}
30+
}
31+

API/ThriveChurchOfficialAPI/ThriveChurchOfficialAPI.Services/Services/TranscriptService.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,24 @@ public async Task<SystemResponse<TranscriptResponse>> GetTranscriptAsync(string
7676
var downloadResponse = await blobClient.DownloadContentAsync();
7777
var content = downloadResponse.Value.Content.ToString();
7878

79-
// Parse the JSON content
80-
var transcript = JsonConvert.DeserializeObject<TranscriptResponse>(content);
81-
82-
if (transcript == null)
79+
// Parse the JSON content from blob (uses camelCase)
80+
var blob = JsonConvert.DeserializeObject<TranscriptBlob>(content);
81+
82+
if (blob == null)
8383
{
84-
return new SystemResponse<TranscriptResponse>(true,
84+
return new SystemResponse<TranscriptResponse>(true,
8585
"Failed to parse transcript data.");
8686
}
8787

88-
// Ensure the MessageId is set
89-
transcript.MessageId = messageId;
90-
91-
// Calculate word count if not present
92-
if (transcript.WordCount == 0 && !string.IsNullOrEmpty(transcript.FullText))
88+
// Map blob DTO to API response (PascalCase)
89+
var transcript = new TranscriptResponse
9390
{
94-
transcript.WordCount = transcript.FullText.Split(
95-
new[] { ' ', '\t', '\n', '\r' },
96-
StringSplitOptions.RemoveEmptyEntries).Length;
97-
}
91+
MessageId = messageId,
92+
Title = blob.Title,
93+
Speaker = blob.Speaker,
94+
FullText = blob.Transcript,
95+
WordCount = blob.WordCount
96+
};
9897

9998
Log.Information("Successfully retrieved transcript for message: {MessageId}", messageId);
10099
return new SystemResponse<TranscriptResponse>(transcript, "Success!");

0 commit comments

Comments
 (0)