Skip to content

Commit

Permalink
Various data and indexing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Webreaper committed Nov 23, 2020
1 parent 7c8dc5c commit efb85ab
Show file tree
Hide file tree
Showing 12 changed files with 527 additions and 22 deletions.
Binary file modified .DS_Store
Binary file not shown.
470 changes: 470 additions & 0 deletions Damselfly.Core/Migrations/20201119225531_ImproveIndexes.Designer.cs

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions Damselfly.Core/Migrations/20201119225531_ImproveIndexes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;

namespace Damselfly.Core.Migrations
{
public partial class ImproveIndexes : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_Images_FileName",
table: "Images",
column: "FileName");
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Images_FileName",
table: "Images");
}
}
}
2 changes: 2 additions & 0 deletions Damselfly.Core/Migrations/ImageContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("FileLastModDate");

b.HasIndex("FileName");

b.HasIndex("FolderId");

b.HasIndex("LastUpdated");
Expand Down
6 changes: 6 additions & 0 deletions Damselfly.Core/Models/ImageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.WithOne(b => b.BasketEntry)
.HasForeignKey<BasketEntry>(e => e.ImageId);

modelBuilder.Entity<Image>()
.HasOne(img => img.MetaData)
.WithOne(meta => meta.Image)
.HasForeignKey<ImageMetaData>(i => i.ImageId);

modelBuilder.Entity<ImageTag>().HasIndex(x => new { x.ImageId, x.TagId }).IsUnique();
modelBuilder.Entity<Image>().HasIndex(x => new { x.FolderId });
modelBuilder.Entity<Image>().HasIndex(x => x.LastUpdated);
modelBuilder.Entity<Image>().HasIndex(x => x.FileName);
modelBuilder.Entity<Image>().HasIndex(x => x.FileLastModDate);
modelBuilder.Entity<Folder>().HasIndex(x => x.FolderScanDate);
modelBuilder.Entity<Folder>().HasIndex(x => x.Path);
Expand Down
13 changes: 8 additions & 5 deletions Damselfly.Core/Services/SearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ private void LoadMoreData(int first, int count)

images = images.Include(x => x.MetaData);

// Always filter by date - because if there's no filter
// set then they'll be set to min/max date.
images = images.Where(x => x.MetaData == null ||
(x.MetaData.DateTaken >= query.MinDate &&
x.MetaData.DateTaken <= query.MaxDate ));
if (query.MinDate > DateTime.MinValue || query.MaxDate < DateTime.MaxValue)
{
// Always filter by date - because if there's no filter
// set then they'll be set to min/max date.
images = images.Where(x => x.MetaData == null ||
(x.MetaData.DateTaken >= query.MinDate &&
x.MetaData.DateTaken <= query.MaxDate));
}

if( query.MinSizeKB > ulong.MinValue )
{
Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Damselfly",
"version": "1.0.81",
"version": "1.0.82",
"description": "Damselfy Desktop App",
"main": "main.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion Damselfly.Web/Shared/DatePickerEx.razor
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@

DateRanges.Add("This year", new DateRange { Start = Jan1ThisYear, End = DateTime.UtcNow });
DateRanges.Add("Last year", new DateRange { Start = Jan1ThisYear.AddYears(-1), End = Jan1ThisYear.AddSeconds(-1) });
DateRanges.Add($"{Jan1ThisYear.AddYears(-1).Year}", new DateRange { Start = Jan1ThisYear.AddYears(-1), End = Jan1ThisYear.AddSeconds(-1) });
DateRanges.Add($"{Jan1ThisYear.AddYears(-2).Year}", new DateRange { Start = Jan1ThisYear.AddYears(-2), End = Jan1ThisYear.AddYears(-1).AddSeconds(-1) });
DateRanges.Add($"{Jan1ThisYear.AddYears(-3).Year}", new DateRange { Start = Jan1ThisYear.AddYears(-3), End = Jan1ThisYear.AddYears(-2).AddSeconds(-1) });
DateRanges.Add($"{Jan1ThisYear.AddYears(-4).Year}", new DateRange { Start = Jan1ThisYear.AddYears(-4), End = Jan1ThisYear.AddYears(-3).AddSeconds(-1) });
DateRanges.Add($"{Jan1ThisYear.AddYears(-5).Year}", new DateRange { Start = Jan1ThisYear.AddYears(-5), End = Jan1ThisYear.AddYears(-4).AddSeconds(-1) });
DateRanges.Add($"{Jan1ThisYear.AddYears(-10).Year}", new DateRange { Start = Jan1ThisYear.AddYears(-10), End = Jan1ThisYear.AddYears(-9).AddSeconds(-1) });
}
}

Expand Down
8 changes: 4 additions & 4 deletions Damselfly.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
SearchService.Instance.PreLoadSearchData();
BasketService.Instance.Initialise();

if (IndexingService.EnableIndexing)
IndexingService.Instance.StartService();
//if (IndexingService.EnableIndexing)
// IndexingService.Instance.StartService();

if (IndexingService.EnableThumbnailGeneration)
ThumbnailService.Instance.StartService();
//if (IndexingService.EnableThumbnailGeneration)
// ThumbnailService.Instance.StartService();

Logging.Log("Preloading complete");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var blazorVirtualScrolling = {
(e) => {
cmp.invokeMethodAsync("VirtualScrollingSetView", blazorVirtualScrolling.getScrollView(ref));


});
}

Expand Down
21 changes: 11 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ ARG RUNTIMEVERSION=5.0-alpine
FROM mcr.microsoft.com/dotnet/aspnet:$RUNTIMEVERSION AS base
WORKDIR /app
EXPOSE 6363
RUN mkdir -p ./Damselfly.Web/wwwroot/desktop
# Copy the mac desktop app into the image (this will be built outside docker)
COPY ./Damselfly.Web/wwwroot/desktop/damselfly-macos.zip /Damselfly.Web/wwwroot/desktop
# Copy the entrypoint script
COPY ./damselfly-entrypoint.sh /
RUN ["chmod", "+x", "/damselfly-entrypoint.sh"]
ADD VERSION .

# First, build the Windows desktop app
# FROM electronuserland/builder:wine as desktop
Expand All @@ -23,7 +16,6 @@ ADD VERSION .
# RUN yarn version --new-version ${DAMSELFLY_VERSION}
# RUN yarn distwin
# WORKDIR "/Damselfly.Desktop/dist"
# RUN ls
# RUN zip /damselfly-win.zip *.*

# Now build the app itself
Expand All @@ -50,11 +42,20 @@ WORKDIR /app
# This may re-copy the desktop/* apps, but who cares.
COPY --from=publish /app/publish .

# Copy the mac desktop app into the image (this will be built outside docker)
# TODO: Maybe do this in the publish step?
RUN mkdir -p ./wwwroot/desktop
COPY ./Damselfly.Web/wwwroot/desktop/damselfly-macos.zip ./wwwroot/desktop
# Copy the entrypoint script
COPY ./damselfly-entrypoint.sh /
RUN ["chmod", "+x", "/damselfly-entrypoint.sh"]
ADD VERSION .


# Add Microsoft fonts that'll be used for watermarking
RUN apk add --no-cache msttcorefonts-installer fontconfig
RUN update-ms-fonts
RUN apk add --no-cache msttcorefonts-installer fontconfig && update-ms-fonts

# Add ExifTool
RUN apk --update add exiftool && rm -rf /var/cache/apk/*

# Make and install exiftool if we want a newer version
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.81
1.0.82

0 comments on commit efb85ab

Please sign in to comment.