Skip to content
Merged
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
2 changes: 2 additions & 0 deletions dev-share-api/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}

[HttpPost("share")]
public async Task<IActionResult> Share([FromBody] UrlRequest request)

Check warning on line 43 in dev-share-api/Controllers/ApiController.cs

View workflow job for this annotation

GitHub Actions / ci

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
var url = request.Url;

Expand Down Expand Up @@ -85,6 +85,7 @@
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
task.Status = "failed";
task.Message = ex.Message;
}
Expand Down Expand Up @@ -159,6 +160,7 @@
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return StatusCode(500, "Search failed due to an internal error.");
}
}
Expand Down
3 changes: 3 additions & 0 deletions dev-share-api/Data/Entities/Resource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
public int Id { get; set; }

public long ResourceId { get; set; }
public string Url { get; set; }

Check warning on line 14 in dev-share-api/Data/Entities/Resource.cs

View workflow job for this annotation

GitHub Actions / ci

Non-nullable property 'Url' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public string NormalizeUrl { get; set; }

Check warning on line 15 in dev-share-api/Data/Entities/Resource.cs

View workflow job for this annotation

GitHub Actions / ci

Non-nullable property 'NormalizeUrl' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public string? Title { get; set; }
public string Content { get; set; }

Check warning on line 17 in dev-share-api/Data/Entities/Resource.cs

View workflow job for this annotation

GitHub Actions / ci

Non-nullable property 'Content' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public List<UserInsight> UserInsights { get; set; }

Check warning on line 18 in dev-share-api/Data/Entities/Resource.cs

View workflow job for this annotation

GitHub Actions / ci

Non-nullable property 'UserInsights' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
2 changes: 2 additions & 0 deletions dev-share-api/Data/Entities/UserInsight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
public int Id { get; set; }

public long ResourceId { get; set; }
public string Content { get; set; }

Check warning on line 13 in dev-share-api/Data/Entities/UserInsight.cs

View workflow job for this annotation

GitHub Actions / ci

Non-nullable property 'Content' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
[ForeignKey("ResourceId")]
public Resource Resource { get; set; }

Check warning on line 15 in dev-share-api/Data/Entities/UserInsight.cs

View workflow job for this annotation

GitHub Actions / ci

Non-nullable property 'Resource' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
3 changes: 2 additions & 1 deletion dev-share-api/Handle/DatabaseShareChainHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ await _resourceService.AddResourceAsync(
{
ResourceId = resourceId,
Content = context.Summary,
Url = context.Url
Url = context.Url,
Title = context.Title
});
await _vectorService.UpsertResourceAsync(
resourceId.ToString(),
Expand Down
13 changes: 5 additions & 8 deletions dev-share-api/Handle/SummarizeShareChainHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ public override async Task<bool> IsSkip(ResourceShareContext context)

protected override async Task<HandlerResult> ProcessAsync(ResourceShareContext context)
{
var prompt = new StringBuilder()
.AppendLine("You will receive an input text and your task is to summarize the article in no more than 100 words.")
.AppendLine("Only return the summary. Do not include any explanation.")
.AppendLine("# Article content:")
.AppendLine($"{context.ExtractResult}")
.ToString();
var summary = await _summaryService.SummarizeAsync(prompt);
context.Summary = summary;

var summary = await _summaryService.SummarizeAsync(context.ExtractResult);
context.Summary = summary.Summary;
context.Title = summary.Title;
return HandlerResult.Success();
}

}
105 changes: 105 additions & 0 deletions dev-share-api/Migrations/20250720042923_AddRescourceTitle.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions dev-share-api/Migrations/20250720042923_AddRescourceTitle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace dev_share_api.Migrations
{
/// <inheritdoc />
public partial class AddRescourceTitle : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Title",
table: "Resources",
type: "nvarchar(max)",
nullable: true);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Title",
table: "Resources");
}
}
}
118 changes: 118 additions & 0 deletions dev-share-api/Migrations/20250720053132_AddTime.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions dev-share-api/Migrations/20250720053132_AddTime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace dev_share_api.Migrations
{
/// <inheritdoc />
public partial class AddTime : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "CreatedAt",
table: "UserInsights",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

migrationBuilder.AddColumn<DateTime>(
name: "UpdatedAt",
table: "UserInsights",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

migrationBuilder.AddColumn<DateTime>(
name: "CreatedAt",
table: "Resources",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

migrationBuilder.AddColumn<DateTime>(
name: "UpdatedAt",
table: "Resources",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CreatedAt",
table: "UserInsights");

migrationBuilder.DropColumn(
name: "UpdatedAt",
table: "UserInsights");

migrationBuilder.DropColumn(
name: "CreatedAt",
table: "Resources");

migrationBuilder.DropColumn(
name: "UpdatedAt",
table: "Resources");
}
}
}
Loading
Loading