Commit ef0e582b authored by HankG's avatar HankG

Update repositories for proper cleanup and methods for R1 query reqs

parent 4353e4f0
...@@ -9,6 +9,7 @@ namespace MySocialPortalDesktop.Factory ...@@ -9,6 +9,7 @@ namespace MySocialPortalDesktop.Factory
{ {
private const string AllPostsRepositoryDbName = "all_posts.db"; private const string AllPostsRepositoryDbName = "all_posts.db";
private const string LinkPreviewRepositoryDbName = "link_preview.db"; private const string LinkPreviewRepositoryDbName = "link_preview.db";
private const string LinkPreviewCacheRepositoryDbName = "link_preview_cache.db";
private const string MainPeopleRepositoryDbName = "all_people.db"; private const string MainPeopleRepositoryDbName = "all_people.db";
private const string ProfileImageRepositoryDbName = "profile_images.db"; private const string ProfileImageRepositoryDbName = "profile_images.db";
private const string TimelineRepositoryDbName = "timeline_cache.db"; private const string TimelineRepositoryDbName = "timeline_cache.db";
...@@ -66,7 +67,7 @@ namespace MySocialPortalDesktop.Factory ...@@ -66,7 +67,7 @@ namespace MySocialPortalDesktop.Factory
private IFileCacheRepository BuildLinkPreviewImageCacheRepository() private IFileCacheRepository BuildLinkPreviewImageCacheRepository()
{ {
return new FileCacheLiteDbRepository(BuildDbPath(LinkPreviewRepositoryDbName)); return new FileCacheLiteDbRepository(BuildDbPath(LinkPreviewCacheRepositoryDbName));
} }
private IFileCacheRepository BuildProfileImageCacheRepository() private IFileCacheRepository BuildProfileImageCacheRepository()
...@@ -101,10 +102,10 @@ namespace MySocialPortalDesktop.Factory ...@@ -101,10 +102,10 @@ namespace MySocialPortalDesktop.Factory
{ {
(AllPostsRepository as IDisposable)?.Dispose(); (AllPostsRepository as IDisposable)?.Dispose();
(LinkPreviewRepository as IDisposable)?.Dispose(); (LinkPreviewRepository as IDisposable)?.Dispose();
(LinkPreviewImageCacheRepository as IDisposable)?.Dispose();
(MainPeopleRepository as IDisposable)?.Dispose(); (MainPeopleRepository as IDisposable)?.Dispose();
(ProfileImageCacheRepository as IDisposable)?.Dispose(); (ProfileImageCacheRepository as IDisposable)?.Dispose();
(TimelineRepository as IDisposable)?.Dispose(); (TimelineRepository as IDisposable)?.Dispose();
(LinkPreviewImageCacheRepository as IDisposable)?.Dispose();
} }
_disposed = true; _disposed = true;
......
...@@ -9,6 +9,7 @@ namespace MySocialPortalLib.Model ...@@ -9,6 +9,7 @@ namespace MySocialPortalLib.Model
public DateTimeOffset CreationTime { get; set; } public DateTimeOffset CreationTime { get; set; }
public string Id { get; set; } public string Id { get; set; }
public string LocalFileName { get; set; } public string LocalFileName { get; set; }
public string OriginalUrl { get; set; } public string OriginalUrl { get; set; }
......
...@@ -82,7 +82,7 @@ namespace MySocialPortalLib.Repository ...@@ -82,7 +82,7 @@ namespace MySocialPortalLib.Repository
if (disposing) if (disposing)
{ {
FileCacheRepository?.Dispose();
} }
_disposed = true; _disposed = true;
......
...@@ -13,5 +13,7 @@ namespace MySocialPortalLib.Repository ...@@ -13,5 +13,7 @@ namespace MySocialPortalLib.Repository
IEnumerable<Post> GetPosts(int maxPosts); IEnumerable<Post> GetPosts(int maxPosts);
IEnumerable<Post> GetPosts(DateTimeOffset newestPostTime, int maxPosts, bool inclusive); IEnumerable<Post> GetPosts(DateTimeOffset newestPostTime, int maxPosts, bool inclusive);
IEnumerable<Post> GetPosts(DateTimeOffset oldestPostTime, DateTimeOffset newestPostTime, int maxPosts, bool inclusive);
} }
} }
\ No newline at end of file
...@@ -69,16 +69,19 @@ namespace MySocialPortalLib.Repository ...@@ -69,16 +69,19 @@ namespace MySocialPortalLib.Repository
public IEnumerable<Post> GetPosts(int maxPosts = DefaultMaxPosts) public IEnumerable<Post> GetPosts(int maxPosts = DefaultMaxPosts)
{ {
return GetDefaultQuery() return GetPosts(DateTimeOffset.MinValue, DateTimeOffset.MaxValue, maxPosts, true);
.Limit(maxPosts)
.ToEnumerable();
} }
public IEnumerable<Post> GetPosts(DateTimeOffset newestPostTime, int maxPosts = DefaultMaxPosts, bool inclusive = true) public IEnumerable<Post> GetPosts(DateTimeOffset newestPostTime, int maxPosts = DefaultMaxPosts, bool inclusive = true)
{
return GetPosts(DateTimeOffset.MinValue, newestPostTime, maxPosts, inclusive);
}
public IEnumerable<Post> GetPosts(DateTimeOffset oldestPostTime, DateTimeOffset newestPostTime, int maxPosts = DefaultMaxPosts, bool inclusive = true)
{ {
var baseQuery = GetDefaultQuery(); var baseQuery = GetDefaultQuery();
var dateFilteredQuery = inclusive ? baseQuery.Where(p => p.PostDateTime <= newestPostTime) var dateFilteredQuery = inclusive ? baseQuery.Where(p => p.PostDateTime >= oldestPostTime && p.PostDateTime <= newestPostTime)
: baseQuery.Where(p => p.PostDateTime < newestPostTime) ; : baseQuery.Where(p => p.PostDateTime > oldestPostTime && p.PostDateTime < newestPostTime) ;
return dateFilteredQuery return dateFilteredQuery
.Limit(maxPosts) .Limit(maxPosts)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment