Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/dotnet-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: RaccoonBlog .NET 8 CI
name: RaccoonBlog .NET 10 CI

on:
push:
Expand All @@ -19,7 +19,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-version: '10.0.x'

- name: Install dependencies for RavenDB
run: |
Expand All @@ -35,4 +35,4 @@ jobs:
- name: Run Tests
run: dotnet test --no-build --configuration Release --verbosity normal
env:
RAVEN_TARGET_FRAMEWORK: 'net8.0'
RAVEN_TARGET_FRAMEWORK: 'net10.0'
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.11" />

<!-- Keep compatible packages -->
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="HtmlAgilityPack" Version="1.6.16" />

<!-- RavenDB packages - ALL v6.0.104 for compatibility -->
<PackageReference Include="RavenDB.Client" Version="6.0.104" />
<PackageReference Include="RavenDB.Embedded" Version="6.0.104" />
<PackageReference Include="RavenDB.Client" Version="7.2.1" />
<PackageReference Include="RavenDB.Embedded" Version="7.2.1" />

<!-- Updated xunit packages for .NET 8 compatibility -->
<PackageReference Include="xunit" Version="2.9.2" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using RaccoonBlog.IntegrationTests.Infrastructure;
using RaccoonBlog.Web.Infrastructure.Common;
using RaccoonBlog.Web.Models;
using RaccoonBlog.Web.Services;
Expand All @@ -10,37 +12,33 @@

namespace RaccoonBlog.IntegrationTests.Web.Services
{
public class PostSchedulingStrategyTests : IDisposable
public class PostSchedulingStrategyTests : IClassFixture<TestWebApplicationFactory>, IDisposable
{
private static EmbeddedServer _embeddedServer;
private static readonly object _lock = new object();

private readonly IServiceScope _scope;
protected DateTimeOffset Now { get; private set; }
protected IDocumentStore DocumentStore { get; private set; }
protected IDocumentSession Session { get; private set; }

public PostSchedulingStrategyTests()
public PostSchedulingStrategyTests(TestWebApplicationFactory factory)
{
// Use EmbeddedServer singleton - StartServer() is called automatically on first GetDocumentStore
lock (_lock)
_scope = factory.Services.CreateScope();
Session = _scope.ServiceProvider.GetRequiredService<IDocumentSession>();
Now = DateTimeOffset.Now;
ClearPosts();
}

private void ClearPosts()
{
var posts = Session.Query<Post>().ToList();
foreach (var post in posts)
{
if (_embeddedServer == null)
{
_embeddedServer = EmbeddedServer.Instance;
// StartServer is called automatically by EmbeddedServer.Instance the first time
// DO NOT call _embeddedServer.StartServer() manually - it will throw on subsequent calls
}
Session.Delete(post);
}

Now = DateTimeOffset.Now;
DocumentStore = _embeddedServer.GetDocumentStore(Guid.NewGuid().ToString());
Session = DocumentStore.OpenSession();
Session.SaveChanges();
}

public virtual void Dispose()
{
Session?.Dispose();
DocumentStore?.Dispose();
_scope?.Dispose();
}

[Fact]
Expand Down
16 changes: 7 additions & 9 deletions RaccoonBlog.Web/Controllers/PostDetailsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ public virtual IActionResult Details(string id, string slug, Guid key)
var nowAsMinutes = DateTimeOffset.Now.AsMinutes();
var tagsToSearch = post.Tags ?? Array.Empty<string>();

var related = RavenSession.Query<Posts_ByTag.Query, Posts_ByTag>()
.Where(p => p.PublishAt < nowAsMinutes && p.Tags.ContainsAny(tagsToSearch))
.OrderByDescending(p => p.PublishAt)
.Take(10)
.Select(p => new PostReference { Id = p.Id, Title = p.Title, PublishedAt = p.PublishAt, Tags = p.Tags })
.ToList()
.Where(p => p.Id != post.Id)
.Take(3)
.ToList();
var related = RavenSession.Query<Posts_ByVector.Query, Posts_ByVector>()
.Where(p => p.PublishAt < DateTimeOffset.Now.AsMinutes())
.VectorSearch(x => x.WithField(p => p.Vector), x => x.ForDocument(post.Id))
.Take(3)
.Skip(1) // skip the current post, always the best match :-)
.Select(p => new PostReference { Id = p.Id, Title = p.Title, PublishedAt = p.PublishAt, Tags = p.Tags})
.ToList();

var comments = RavenSession.Load<PostComments>(post.CommentsId) ?? new PostComments();
var vm = new PostViewModel
Expand Down
54 changes: 24 additions & 30 deletions RaccoonBlog.Web/Infrastructure/Indexes/Posts_ByVector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,32 @@

namespace RaccoonBlog.Web.Infrastructure.Indexes
{
// DISABLED: Vector Search requires RavenDB v7+
// This index uses LoadVector() which is not available in v6.0.104
// Temporarily disabled for .NET 8 migration compatibility

/*
public class Posts_ByVector : AbstractIndexCreationTask<Post, Posts_ByTag.Query>
{
public class Query
{
public string Id { get; set; }
public class Posts_ByVector : AbstractIndexCreationTask<Post, Posts_ByTag.Query>
{
public class Query
{
public string Id { get; set; }

public string Title { get; set; }
public string Title { get; set; }

public DateTimeOffset PublishAt { get; set; }
public DateTimeOffset PublishAt { get; set; }

public object Vector { get; set; }

public ICollection<string> Tags { get; set; }
}
public object Vector { get; set; }
public ICollection<string> Tags { get; set; }
}

public Posts_ByVector()
{
SearchEngineType = Raven.Client.Documents.Indexes.SearchEngineType.Corax;
Map = posts => from post in posts
where post.PublishAt != null
select new
{
Vector = LoadVector("Body", "postsbyvector"),
PublishAt = post.PublishAt,
Tags = post.Tags
};
}
}
*/
public Posts_ByVector()
{
SearchEngineType = Raven.Client.Documents.Indexes.SearchEngineType.Corax;
Map = posts => from post in posts
where post.PublishAt != null
select new
{
Vector = LoadVector("Body", "postsbyvector"),
PublishAt = post.PublishAt,
Tags = post.Tags
};
}
}
}
10 changes: 3 additions & 7 deletions RaccoonBlog.Web/RaccoonBlog.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,13 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="8.0.0" />

<!-- AutoMapper packages - Upgraded to 12.x for .NET 8 compatibility -->
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />

<PackageReference Include="AutoMapper" Version="13.0.0" />
<!-- Keep compatible packages -->
<PackageReference Include="FluentScheduler" Version="5.3.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.6.16" />
<PackageReference Include="JetBrains.Annotations" Version="11.1.0" />
<PackageReference Include="Lambda2Js.Signed" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="8.0.22" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="10.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.11" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
Expand Down Expand Up @@ -90,7 +86,7 @@
<PackageReference Include="RedditSharp" Version="2.0.0" />

<!-- RavenDB packages - ALL v6.0.104 for compatibility -->
<PackageReference Include="RavenDB.Client" Version="6.0.104" />
<PackageReference Include="RavenDB.Client" Version="7.2.1" />
<PackageReference Include="RavenDB.Embedded" Version="6.0.104" />
<PackageReference Include="RavenDB.TestDriver" Version="6.0.104" />
<PackageReference Include="WilderMinds.MetaWeblog" Version="5.1.3" />
Expand Down
Loading