-
Notifications
You must be signed in to change notification settings - Fork 0
Summarise Subreddits #71
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
Merged
Merged
Changes from 137 commits
Commits
Show all changes
142 commits
Select commit
Hold shift + click to select a range
e314528
Add ContentExtractorStrategy
elzik 9001db8
Add additional code coverage
elzik 540d466
Use ContentExtractorStrategy with only default extractor
elzik faa20b6
Give default content extractor a better name
elzik 23f466a
Move content extractors to their own namespace
elzik 258b8b5
Supress warnings needed for tests
elzik 8d3de23
Fix test not using cirrect instance
elzik 0c1e8ec
Rename tests & adjust namespaces to match class being tested
elzik cadae36
Remove repeated test
elzik 3c2eef3
Add CanHandle tests
elzik f4b3630
Add partial SubRedditContentExtractor
elzik 41665fb
Rename WebPageDownloader - it downloads any text not just web pages
elzik 5675b09
Rename test files to match class names
elzik 7f043d4
Add TryGet to HttpDownloader
elzik 52dc3f8
Complete SubRedditContentExtractor.ExtractAsync implementation
elzik f0d9bf7
Ignore local test playlists
elzik 464b781
Refine SubRedditExtractorTests
elzik b887a80
Ensure sub-reddit URLs are genrated regardelss of whether they have a…
elzik cb48db3
Log strategy used
elzik 789952d
Make SubRedditContentExtractor available
elzik 6f86a1b
Move Reddit concerns to its own namespace and fix image extraction
elzik c46341b
Use Shouldly for asserts
elzik 96fd565
Add client for posts new in a Subreddit
elzik 2353cd2
Code quality fixes
elzik 5cc945e
Add abour subreddit to reddit client
elzik 90241c3
Initial reddit posts client
elzik c7af966
Skip reddit tests which cannot run in CI
elzik 5efc53b
Ensure all reddit-based tests are skipped
elzik c3bc746
Refine RedditPostClient and assert main post os correct
elzik 2bf045c
Increae RedditPostClient test coverage
elzik 4080d57
Code quality fixes
elzik ea61877
Upgrade Sonar & fix code quality issues
elzik 8355024
Code quality fixes
elzik fe47956
Simply array indexing
elzik 77e1936
Make converter redditspecific by writing in the same format as reddit…
elzik c0e0f44
Add RedditDateTimeConverter tests
elzik 379e8f1
Code quality fixes
elzik 729ab1a
Initial tests for RedditRepliesConverter
elzik a4b8a4e
Fix failing tests
elzik 7a86789
Merge branch 'main' into summarise-sub-reddit
elzik e95a89a
Merge branch 'main' into summarise-sub-reddit
elzik e0d777a
Make test less brittle and account for possible post deletion in the …
elzik 82114ec
Add simplified version of reddit post and client
elzik b65ae9a
Move reply converstion into transformer
elzik d6876f4
Return Tasks for async methods
elzik c1d632b
Add NSubstitute analysers
elzik 3041b77
Don’t await NSubstitute Received verification
elzik fb396b4
Fix culture-unsafe formatting and unnecessary WriteRawValue
elzik abbfe23
Avoid local-time skew when value.Kind is Unspecified
elzik 10b02b8
Add explicit using for Reddit.Client and remove the redundant self-na…
elzik 6df7ced
Fix locale‑dependent JSON construction for doubles
elzik 02822ea
Merge branch 'summarise-sub-reddit' of https://github.com/elzik/breef…
elzik 68f60e8
Ensure that tests fail is the wrong extractor is used
elzik d7dd68e
Add guard against Children being null
elzik 321a49f
Avoid using ThrowsAsync for throwing exeptions from mocks
elzik d89594d
Add a null-guard for rawRedditPost
elzik d734a12
Add ContentExtractorStrategy
elzik 03eef6c
Add additional code coverage
elzik 02cdb7d
Use ContentExtractorStrategy with only default extractor
elzik a923a1f
Give default content extractor a better name
elzik f40cef2
Move content extractors to their own namespace
elzik fec3b83
Supress warnings needed for tests
elzik a355743
Fix test not using cirrect instance
elzik 45f06a4
Rename tests & adjust namespaces to match class being tested
elzik 380b386
Remove repeated test
elzik fe67ad0
Add CanHandle tests
elzik 0dd1fa2
Add partial SubRedditContentExtractor
elzik 5a61dd0
Rename WebPageDownloader - it downloads any text not just web pages
elzik 0109efc
Rename test files to match class names
elzik c39d84f
Add TryGet to HttpDownloader
elzik 52578e7
Complete SubRedditContentExtractor.ExtractAsync implementation
elzik 00acc98
Ignore local test playlists
elzik cb60afa
Refine SubRedditExtractorTests
elzik 18c49e7
Ensure sub-reddit URLs are genrated regardelss of whether they have a…
elzik 3bfd2c9
Log strategy used
elzik 6d8813e
Make SubRedditContentExtractor available
elzik a90404b
Move Reddit concerns to its own namespace and fix image extraction
elzik d1329ac
Use Shouldly for asserts
elzik 261b65a
Add client for posts new in a Subreddit
elzik a8b53fd
Code quality fixes
elzik c6c1890
Add abour subreddit to reddit client
elzik 85f4555
Initial reddit posts client
elzik f5ca510
Skip reddit tests which cannot run in CI
elzik 5bb90ad
Ensure all reddit-based tests are skipped
elzik db08ecf
Refine RedditPostClient and assert main post os correct
elzik 79211f5
Increae RedditPostClient test coverage
elzik 6387832
Code quality fixes
elzik e307205
Upgrade Sonar & fix code quality issues
elzik f068c1a
Code quality fixes
elzik 4e234cc
Simply array indexing
elzik 2051b29
Make converter redditspecific by writing in the same format as reddit…
elzik 58d1f48
Add RedditDateTimeConverter tests
elzik 4cb938f
Code quality fixes
elzik dbd62d8
Initial tests for RedditRepliesConverter
elzik 5a600d7
Fix failing tests
elzik d346935
Make test less brittle and account for possible post deletion in the …
elzik 5e8dd64
Add simplified version of reddit post and client
elzik 27c551b
Move reply converstion into transformer
elzik b7c4819
Return Tasks for async methods
elzik 6f83d35
Add NSubstitute analysers
elzik 181d345
Don’t await NSubstitute Received verification
elzik e88e44c
Fix culture-unsafe formatting and unnecessary WriteRawValue
elzik 8eba336
Avoid local-time skew when value.Kind is Unspecified
elzik ea5fb57
Fix locale‑dependent JSON construction for doubles
elzik 999fc80
Add explicit using for Reddit.Client and remove the redundant self-na…
elzik 767b2d9
Ensure that tests fail is the wrong extractor is used
elzik c97ea9b
Add guard against Children being null
elzik 1046d47
Avoid using ThrowsAsync for throwing exeptions from mocks
elzik fc76c52
Add a null-guard for rawRedditPost
elzik 268b76d
Merge branch 'summarise-sub-reddit' of https://github.com/elzik/breef…
elzik 3e74dfc
Merge branch 'main' into summarise-sub-reddit
elzik 42751f4
Update tests/Elzik.Breef.Infrastructure.Tests.Unit/ContentExtractors/…
elzik c029f7d
Update tests/Elzik.Breef.Infrastructure.Tests.Integration/ContentExtr…
elzik f3a5bbe
Update tests/Elzik.Breef.Infrastructure.Tests.Unit/ContentExtractors/…
elzik 8909784
Upgrade Sonar analysers
elzik ac24e98
Merge branch 'main' into summarise-sub-reddit
elzik 61e419e
Add content extractor for reddit posts
elzik 4b87fce
Improve tests
elzik 5875c2c
Code quality fixes
elzik 7696ed0
Add ability to configyre Reddit URLs and code quality fixes
elzik 9673297
Code quality fixes
elzik 0b5ccf2
Ensure that imgae fallback takes place in all cases
elzik da1782f
Code quality fixes
elzik f9a944c
Remove tests that do not test anything
elzik 22dbad3
Add timeout to Docker tests
elzik 1a6d54a
Code quality fixes
elzik cd2c236
Remove unecessary usings
elzik 32406de
Code quality fixes
elzik 2a1c6d5
Make reddit fallback image configurable
elzik 3eb41f2
Rename existing types to Raw pattern
elzik bcefc60
Create new domain NewInSubreddit type
elzik 139dd4e
Create transformer interface and implementation
elzik 3ec3329
Create new SubredditClient following the established pattern
elzik 7615d11
Update SubRedditContentExtractor to use new client
elzik 66cf3de
Code quality fixes
elzik 36edc81
Merge branch 'main' into summarise-sub-reddit
elzik 0c613f9
Remove unecessary wrapping of HttpClient
elzik 10b12c3
Fix readme indentation
elzik d9bc281
Ensure HTTP client is disposed in tests
elzik 10702f7
Fix indentation
elzik 49ae929
Dispose of HttpResponseMessage to prevent resource leak
elzik 245cc26
Add URL with query string test
elzik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -396,3 +396,4 @@ FodyWeavers.xsd | |
|
|
||
| # JetBrains Rider | ||
| *.sln.iml | ||
| /tests/LocalPlaylists | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| using Elzik.Breef.Domain; | ||
| using System.Diagnostics; | ||
|
|
||
| namespace Elzik.Breef.Application | ||
| { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
src/Elzik.Breef.Infrastructure/ContentExtractors/ContentExtractorStrategy.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| using Elzik.Breef.Domain; | ||
| using Microsoft.Extensions.Logging; | ||
|
|
||
| namespace Elzik.Breef.Infrastructure.ContentExtractors | ||
| { | ||
| public class ContentExtractorStrategy : IContentExtractor | ||
| { | ||
| private readonly ILogger<ContentExtractorStrategy> _logger; | ||
| private readonly List<IContentExtractor> _extractors; | ||
|
|
||
| public ContentExtractorStrategy(ILogger<ContentExtractorStrategy> logger, | ||
| IEnumerable<IContentExtractor> specificExtractors, IContentExtractor defaultExtractor) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(logger); | ||
| ArgumentNullException.ThrowIfNull(specificExtractors); | ||
| ArgumentNullException.ThrowIfNull(defaultExtractor); | ||
|
|
||
| _logger = logger; | ||
|
|
||
| if (specificExtractors.Contains(defaultExtractor)) | ||
| throw new ArgumentException("Default extractor should not be in the specific extractors list."); | ||
|
|
||
| _extractors = [.. specificExtractors, defaultExtractor]; | ||
| } | ||
|
|
||
| public bool CanHandle(string webPageUrl) => true; | ||
|
|
||
| public async Task<Extract> ExtractAsync(string webPageUrl) | ||
| { | ||
| var extractor = _extractors.First(e => e.CanHandle(webPageUrl)); | ||
|
|
||
| _logger.LogInformation("Extraction will be provided for by {ExtractorName}", extractor.GetType().Name); | ||
|
|
||
| return await extractor.ExtractAsync(webPageUrl); | ||
| } | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/Elzik.Breef.Infrastructure/ContentExtractors/Reddit/Client/AboutSubreddit.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace Elzik.Breef.Infrastructure.ContentExtractors.Reddit.Client; | ||
|
|
||
| public class AboutSubreddit | ||
| { | ||
| [JsonPropertyName("data")] | ||
| public AboutSubredditData? Data { get; set; } | ||
| } | ||
|
|
||
| public class AboutSubredditData | ||
| { | ||
| [JsonPropertyName("public_description")] | ||
| public string? PublicDescription { get; set; } | ||
|
|
||
| [JsonPropertyName("icon_img")] | ||
| public string? IconImg { get; set; } | ||
|
|
||
| [JsonPropertyName("banner_img")] | ||
| public string? BannerImg { get; set; } | ||
|
|
||
| [JsonPropertyName("banner_background_image")] | ||
| public string? BannerBackgroundImage { get; set; } | ||
|
|
||
| [JsonPropertyName("mobile_banner_image")] | ||
| public string? MobileBannerImage { get; set; } | ||
|
|
||
| [JsonPropertyName("community_icon")] | ||
| public string? CommunityIcon { get; set; } | ||
| } |
6 changes: 6 additions & 0 deletions
6
...zik.Breef.Infrastructure/ContentExtractors/Reddit/Client/IRawNewInSubredditTransformer.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| namespace Elzik.Breef.Infrastructure.ContentExtractors.Reddit.Client; | ||
|
|
||
| public interface IRawNewInSubredditTransformer | ||
| { | ||
| Task<NewInSubreddit> Transform(RawNewInSubreddit rawNewInSubreddit); | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/Elzik.Breef.Infrastructure/ContentExtractors/Reddit/Client/IRedditPostClient.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace Elzik.Breef.Infrastructure.ContentExtractors.Reddit.Client | ||
| { | ||
| public interface IRedditPostClient | ||
| { | ||
| Task<RedditPost> GetPost(string postId); | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/Elzik.Breef.Infrastructure/ContentExtractors/Reddit/Client/ISubredditClient.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| namespace Elzik.Breef.Infrastructure.ContentExtractors.Reddit.Client; | ||
|
|
||
| public interface ISubredditClient | ||
| { | ||
| Task<NewInSubreddit> GetNewInSubreddit(string subRedditName); | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/Elzik.Breef.Infrastructure/ContentExtractors/Reddit/Client/NewInSubreddit.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| namespace Elzik.Breef.Infrastructure.ContentExtractors.Reddit.Client; | ||
|
|
||
| public class NewInSubreddit | ||
| { | ||
| public List<RedditPost> Posts { get; set; } = []; | ||
| } |
30 changes: 30 additions & 0 deletions
30
...Elzik.Breef.Infrastructure/ContentExtractors/Reddit/Client/Raw/FlexibleStringConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| using System.Text.Json; | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace Elzik.Breef.Infrastructure.ContentExtractors.Reddit.Client.Raw; | ||
|
|
||
| public class FlexibleStringConverter : JsonConverter<string?> | ||
| { | ||
| public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
| { | ||
| return reader.TokenType switch | ||
| { | ||
| JsonTokenType.String => reader.GetString(), | ||
| JsonTokenType.Number => reader.GetInt64().ToString(), | ||
| JsonTokenType.Null => null, | ||
| _ => throw new JsonException($"Cannot convert {reader.TokenType} to string") | ||
| }; | ||
| } | ||
|
|
||
| public override void Write(Utf8JsonWriter writer, string? value, JsonSerializerOptions options) | ||
| { | ||
| if (value == null) | ||
| { | ||
| writer.WriteNullValue(); | ||
| } | ||
| else | ||
| { | ||
| writer.WriteStringValue(value); | ||
| } | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/Elzik.Breef.Infrastructure/ContentExtractors/Reddit/Client/Raw/IRawRedditPostClient.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| using Refit; | ||
|
|
||
| namespace Elzik.Breef.Infrastructure.ContentExtractors.Reddit.Client.Raw | ||
| { | ||
| public interface IRawRedditPostClient | ||
| { | ||
| [Get("/comments/{postId}.json")] | ||
| [Headers("User-Agent: breef/1.0.0 (https://github.com/elzik/breef)")] | ||
| Task<RawRedditPost> GetPost(string postId); | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
...zik.Breef.Infrastructure/ContentExtractors/Reddit/Client/Raw/IRawRedditPostTransformer.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| namespace Elzik.Breef.Infrastructure.ContentExtractors.Reddit.Client.Raw; | ||
|
|
||
| public interface IRawRedditPostTransformer | ||
| { | ||
| RedditPost Transform(RawRedditPost rawRedditPost); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.