Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add the estimated reading time to the index #20

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Childrens-Social-Care-CPD-Indexer/Core/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal class Content : IContent
public List<IContent>? Items { get; set; }
public IContent? Navigation { get; set; }
public IContent? RelatedContent { get; set; }
public int? EstimatedReadingTime { get; set; }

[JsonProperty("$metadata")]
public ContentfulMetadata? Metadata { get; set; }
Expand Down
9 changes: 6 additions & 3 deletions src/Childrens-Social-Care-CPD-Indexer/Core/CpdDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ internal partial class CpdDocument(string id)
[SearchableField(AnalyzerName = LexicalAnalyzerName.Values.EnLucene)]
public string? Body { get; set; }

[SimpleField(IsSortable = true, IsFilterable = true)]
[SimpleField(IsSortable = true)]
public DateTimeOffset? CreatedAt { get; set; }

[SimpleField(IsSortable = true, IsFilterable = true)]
[SimpleField(IsSortable = true)]
public DateTimeOffset? UpdatedAt { get; set; }


[SimpleField]
public int? EstimatedReadingTime { get; set; }

[SimpleField(IsFilterable = true, IsFacetable = true)]
public IEnumerable<string>? Tags { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private static CpdDocument BuildResourceDocument(Content content)
Body = content.SearchSummary,
CreatedAt = content.Sys!.CreatedAt.HasValue ? new DateTimeOffset(content.Sys.CreatedAt.Value) : null,
UpdatedAt = content.Sys!.UpdatedAt.HasValue ? new DateTimeOffset(content.Sys.UpdatedAt.Value) : null,
EstimatedReadingTime = content.EstimatedReadingTime,
Tags = tags
};
}
Expand Down