From e7fa35921395bd65a32186a5b0e1de93584017f7 Mon Sep 17 00:00:00 2001 From: Mark Otway Date: Tue, 20 Sep 2022 23:30:11 +0100 Subject: [PATCH] Fix tag writing --- .DS_Store | Bin 14340 -> 14340 bytes .../Models/Entities/Tag.cs | 8 ++- Damselfly.Core/Damselfly.Core.csproj | 62 +++++++++--------- Damselfly.Core/Database/BaseModel.cs | 7 +- .../ScopedServices/BasketService.cs | 9 ++- Damselfly.Core/Services/MetaDataService.cs | 2 +- .../Damselfly.Migrations.Sqlite.csproj | 12 ++-- 7 files changed, 51 insertions(+), 49 deletions(-) diff --git a/.DS_Store b/.DS_Store index 3e3b269aa67f679a21b8f54fd80ef9bcafff1369..edc0f19c811978f31c2efd2620bbac46929621eb 100644 GIT binary patch delta 1321 zcmd6nU2GIp6vxm1_G^cmy0hJGx4YZ!E@|2Z7;(1yLB}XIwNPk*Hn6mSfx3ku*|==i zPN~6$6cl|>H0n)2q6XrFAFU~x<(u%45CTNQ1F41(z7i6icqvh0G#c-AY9c7{$;5fM zXU_lJ+&Sm|=A2!*UAgzVQ2$N$NoR?Nh(hB1YLEE3u~f`c=ZoF0t?uSnL<=X3=IvT| z#E2%ea7-6d^)dW)XPxMEjftOY+r^TK<&k)QE|a!~bp0AwQE^FWnM0YydAUEix~F%| z+CEj?YMCp|Oll}SY__F_OiR>MZCTGBD*dY2r&bK7%~!f|L+OF6)ng7?(kjZt z6W*HH^>d$!8PB#Z?pQJDR9zLkk_*ed6kMEg>s`FjKSxnhj-(||vEv$_uc(%id?}sX zG_Cj}JnB$4DXTN7elufB3Eu2bJC)vH`%|_kPkyHIgVC0#ycGG=walG)u? zrnR^h;wokw<7v*-VhP!fEv)5S9PoPnBXXDM3SFh!bWf7|9Yt`!i!d6XNlXjTg6GkO zMG{r_C{|+CG_O8Ms~;PYK~@rbSuz{Jc8p>NcH%AU#yiv8_TeLZj8E_xzQC6lLmr25 z6vuEJCvXnm;d@-eok#dAe~1p@N9mVS8>MIqiElk_FV|)gRVzvk^bV*|=g_m)$ zs`Y~#V^H8^i!o|UcCigM6U8hl;$jGjUU(y$!z?BeV@!0@t6k}~V_P&P-e`7ip7Z>l zljl7D{PN7kXXEp|u)o{4x)(*9DcxA*pIRr2&54Aw!R>KqZol9Ej6+Mf-JW_rZ#Q9% zTU8aWh_}r=U|f>CUYA2_aQpZno0)6sKHgT?ZK(~#qY-`D<@y#hD?2CGAjx_8Y)?gC zFz^@~;tM6ke7*2Q+pwaX)WiMZXmC0*6K)MohxMVz=tOKFaw=>h|2&Z2DJZS9K2W>g z>wl#A@X?;Fy^67rnHV1_>HyH_hQiUbmjS1F_(EShhF0G8Ktb5f5o4 zU1Wqzkp!6|uaRZ)KG`6jk*nl8@+0|$+y+3AgIwgpges`eU_~t+f)jOUL@U~G82vbg z<9HIo7{fSXh+`7T86@!>UcifZ35(!3jWc))=Wreu@E%t2F+RZ+e1>9ozT;H*pKU zQqVkVqQ$g?s#K#kYNtMWfHu(%+CzKOgHvP-Jduf+K!?O-k1!M@<3#6CV_{8HpNWT} z6CpzA*?%XiwjXKlV4b^Uo&Sj}KUWeF1dXLmg{ex8fFo^{l~k--vz`16rl{& zaKVQ|0$C6GFn|CC1-21{Fq%R)A;3*R$J2OLuzOz6dl_?h74ulY>v#iirU+iZGA`m0 zF5?4yh>x(24SbGGe1R|VHE!U0?4$-alfO`P?K(+E{LJ4jyO!(q`5l^ ImageTags { get; init; } = new(); diff --git a/Damselfly.Core/Damselfly.Core.csproj b/Damselfly.Core/Damselfly.Core.csproj index deec1fed..a23a3a56 100644 --- a/Damselfly.Core/Damselfly.Core.csproj +++ b/Damselfly.Core/Damselfly.Core.csproj @@ -5,9 +5,9 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -16,37 +16,37 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/Damselfly.Core/Database/BaseModel.cs b/Damselfly.Core/Database/BaseModel.cs index 625a2a92..7acb4445 100644 --- a/Damselfly.Core/Database/BaseModel.cs +++ b/Damselfly.Core/Database/BaseModel.cs @@ -79,7 +79,6 @@ public async Task BulkInsert(DbSet collection, List itemsToSave) try { var bulkConfig = new BulkConfig { SetOutputIdentity = true, BatchSize = 500 }; - await this.BulkInsertAsync(itemsToSave, bulkConfig); success = true; @@ -113,11 +112,7 @@ public async Task BulkUpdate(DbSet collection, List itemsToSave) var success = false; try { - collection.UpdateRange(itemsToSave); - await SaveChangesAsync(); - - // TODO: Replace when EFCore 7 has this - //await db.BulkUpdateAsync(itemsToSave); + await this.BulkUpdateAsync(itemsToSave); success = true; } diff --git a/Damselfly.Core/ScopedServices/BasketService.cs b/Damselfly.Core/ScopedServices/BasketService.cs index 399a45cc..8612810a 100644 --- a/Damselfly.Core/ScopedServices/BasketService.cs +++ b/Damselfly.Core/ScopedServices/BasketService.cs @@ -329,18 +329,23 @@ public async Task GetDefaultBasket(int? userId) // Get the first shared defaultBasket = await db.Baskets .Include(x => x.BasketEntries) + .OrderBy( x => x.Name ) .FirstOrDefaultAsync(x => x.UserId == null); - if ( defaultBasket == null ) + if (defaultBasket == null) + { // Get the first default basket defaultBasket = await db.Baskets .Include(x => x.BasketEntries) .FirstOrDefaultAsync(x => x.Name == s_DefaultBasket); + } if ( defaultBasket == null ) { // Probably shouldn't ever happen, but just pick the first one - defaultBasket = db.Baskets.First(); + defaultBasket = await db.Baskets + .OrderBy( x => x.Name ) + .FirstAsync(); // TODO: If still null, should we create one? throw new ArgumentException("No baskets - this is unexpected!"); diff --git a/Damselfly.Core/Services/MetaDataService.cs b/Damselfly.Core/Services/MetaDataService.cs index 7fb2fc32..6b3a98bd 100644 --- a/Damselfly.Core/Services/MetaDataService.cs +++ b/Damselfly.Core/Services/MetaDataService.cs @@ -717,7 +717,7 @@ private async Task WriteTagsForImage(Image image, List imageKeyword { var addWatch = new Stopwatch("AddTagsInsert"); await db.BulkInsert(db.ImageTags, toAdd); - ; + addWatch.Stop(); } diff --git a/Damselfly.Migrations.Sqlite/Damselfly.Migrations.Sqlite.csproj b/Damselfly.Migrations.Sqlite/Damselfly.Migrations.Sqlite.csproj index 368b4583..900b68be 100644 --- a/Damselfly.Migrations.Sqlite/Damselfly.Migrations.Sqlite.csproj +++ b/Damselfly.Migrations.Sqlite/Damselfly.Migrations.Sqlite.csproj @@ -1,21 +1,21 @@ - + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + - - + +