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
{
private const string AllPostsRepositoryDbName = "all_posts.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 ProfileImageRepositoryDbName = "profile_images.db";
private const string TimelineRepositoryDbName = "timeline_cache.db";
......@@ -66,7 +67,7 @@ namespace MySocialPortalDesktop.Factory
private IFileCacheRepository BuildLinkPreviewImageCacheRepository()
{
return new FileCacheLiteDbRepository(BuildDbPath(LinkPreviewRepositoryDbName));
return new FileCacheLiteDbRepository(BuildDbPath(LinkPreviewCacheRepositoryDbName));
}
private IFileCacheRepository BuildProfileImageCacheRepository()
......@@ -101,10 +102,10 @@ namespace MySocialPortalDesktop.Factory
{
(AllPostsRepository as IDisposable)?.Dispose();
(LinkPreviewRepository as IDisposable)?.Dispose();
(LinkPreviewImageCacheRepository as IDisposable)?.Dispose();
(MainPeopleRepository as IDisposable)?.Dispose();
(ProfileImageCacheRepository as IDisposable)?.Dispose();
(TimelineRepository as IDisposable)?.Dispose();
(LinkPreviewImageCacheRepository as IDisposable)?.Dispose();
}
_disposed = true;
......
......@@ -9,6 +9,7 @@ namespace MySocialPortalLib.Model
public DateTimeOffset CreationTime { get; set; }
public string Id { get; set; }
public string LocalFileName { get; set; }
public string OriginalUrl { get; set; }
......
......@@ -82,7 +82,7 @@ namespace MySocialPortalLib.Repository
if (disposing)
{
FileCacheRepository?.Dispose();
}
_disposed = true;
......
......@@ -13,5 +13,7 @@ namespace MySocialPortalLib.Repository
IEnumerable<Post> GetPosts(int maxPosts);
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
public IEnumerable<Post> GetPosts(int maxPosts = DefaultMaxPosts)
{
return GetDefaultQuery()
.Limit(maxPosts)
.ToEnumerable();
return GetPosts(DateTimeOffset.MinValue, DateTimeOffset.MaxValue, maxPosts, 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 dateFilteredQuery = inclusive ? baseQuery.Where(p => p.PostDateTime <= newestPostTime)
: baseQuery.Where(p => p.PostDateTime < newestPostTime) ;
var dateFilteredQuery = inclusive ? baseQuery.Where(p => p.PostDateTime >= oldestPostTime && p.PostDateTime <= newestPostTime)
: baseQuery.Where(p => p.PostDateTime > oldestPostTime && p.PostDateTime < newestPostTime) ;
return dateFilteredQuery
.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