Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Twitter/X workflow task to match updated view names #15930

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
66864b5
Rename workflow task to match updated view names to resolve missing s…
davidpuplava Apr 30, 2024
62af19b
Add data migration to update existing workflows to use updated Twiite…
davidpuplava May 2, 2024
ae4d618
Refactor content item migrations to match how it's done in Lucene Sea…
davidpuplava May 3, 2024
b3dd976
Refactor unnecessary method call inline to calling method to remove w…
davidpuplava May 8, 2024
c55b807
Merge branch 'main' into davidpuplava/update-x-status-task-shape-not-…
MikeAlhayek May 16, 2024
5ba3d09
Merge branch 'main' into davidpuplava/update-x-status-task-shape-not-…
Piedone Jun 20, 2024
41e5642
Merge tag 'before-formatting
davidpuplava Aug 15, 2024
b95fec7
Format code
davidpuplava Aug 16, 2024
7941494
Merge tag 'formatting'
davidpuplava Aug 16, 2024
17160a6
Refactor Twitter to X migration to simplify database logic; edited na…
davidpuplava Aug 16, 2024
7133943
Merge remote-tracking branch 'upstream/main' into davidpuplava/update…
davidpuplava Aug 16, 2024
2916586
Simplify using expressions for database operations
davidpuplava Aug 16, 2024
43419a9
Merge remote-tracking branch 'upstream/main' into davidpuplava/update…
davidpuplava Aug 17, 2024
ba89043
Rename types/classes/ids back to before X/Twitter rebrand; removed mi…
davidpuplava Aug 17, 2024
e1679a4
Update X/Twitter documentation links in Admin UI
davidpuplava Aug 19, 2024
9a1d3d4
Merge remote-tracking branch 'upstream/main' into davidpuplava/update…
davidpuplava Aug 19, 2024
14e60dc
Remove reference to YesSql project previously added when Migration ex…
davidpuplava Aug 20, 2024
c9cecb0
Remove unused using statement
davidpuplava Aug 20, 2024
84542b9
Fix typo in documentation link to X/Twitter integration docs
davidpuplava Aug 20, 2024
31100c5
Merge remote-tracking branch 'upstream/main' into davidpuplava/update…
davidpuplava Aug 20, 2024
a4504f3
Remove another unused using statement
davidpuplava Aug 20, 2024
8d16b9d
Merge branch 'main' into davidpuplava/update-x-status-task-shape-not-…
hishamco Aug 20, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using Dapper;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using OrchardCore.Data;
using OrchardCore.Data.Migration;
using OrchardCore.Environment.Shell;
using OrchardCore.Environment.Shell.Descriptor.Models;
using OrchardCore.Environment.Shell.Scope;
using YesSql;

namespace OrchardCore.Twitter.Migrations;

public class TwitterMigrations : DataMigration
Piedone marked this conversation as resolved.
Show resolved Hide resolved
{
private readonly ShellDescriptor _shellDescriptor;

public TwitterMigrations(ShellDescriptor shellDescriptor)
{
_shellDescriptor = shellDescriptor;
}

public int Create()
Piedone marked this conversation as resolved.
Show resolved Hide resolved
{
if (_shellDescriptor.WasFeatureAlreadyInstalled("OrchardCore.Twitter"))
{
Upgrade();
}

return 1;
}

private void Upgrade()

Check failure on line 33 in src/OrchardCore.Modules/OrchardCore.Twitter/Migrations/TwitterMigrations.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

Member 'Upgrade' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check failure on line 33 in src/OrchardCore.Modules/OrchardCore.Twitter/Migrations/TwitterMigrations.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

Member 'Upgrade' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check failure on line 33 in src/OrchardCore.Modules/OrchardCore.Twitter/Migrations/TwitterMigrations.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

Member 'Upgrade' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check failure on line 33 in src/OrchardCore.Modules/OrchardCore.Twitter/Migrations/TwitterMigrations.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

Member 'Upgrade' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)
{
ShellScope.AddDeferredTask(async scope =>
{
var session = scope.ServiceProvider.GetRequiredService<ISession>();
var dbConnectionAccessor = scope.ServiceProvider.GetService<IDbConnectionAccessor>();
var logger = scope.ServiceProvider.GetService<ILogger<TwitterMigrations>>();
var tablePrefix = session.Store.Configuration.TablePrefix;
var documentTableName = session.Store.Configuration.TableNameConvention.GetDocumentTable();
var table = $"{session.Store.Configuration.TablePrefix}{documentTableName}";

logger.LogDebug("Updating Twitter/X Workflow Items");

await using var connection = dbConnectionAccessor.CreateConnection();
await connection.OpenAsync();
await using var transaction = await connection.BeginTransactionAsync(session.Store.Configuration.IsolationLevel);
var dialect = session.Store.Configuration.SqlDialect;
Piedone marked this conversation as resolved.
Show resolved Hide resolved

try
{
var quotedTableName = dialect.QuoteForTableName(table, session.Store.Configuration.Schema);
var quotedContentColumnName = dialect.QuoteForColumnName("Content");
var quotedTypeColumnName = dialect.QuoteForColumnName("Type");

var updateCmd = $"UPDATE {quotedTableName} SET {quotedContentColumnName} = REPLACE({quotedContentColumnName}, 'UpdateTwitterStatusTask', 'UpdateXStatusTask') WHERE {quotedTypeColumnName} = 'OrchardCore.Workflows.Models.WorkflowType, OrchardCore.Workflows.Abstractions'";

await transaction.Connection.ExecuteAsync(updateCmd, null, transaction);

await transaction.CommitAsync();
}
catch (Exception e)
{
await transaction.RollbackAsync();
logger.LogError(e, "An error occurred while updating Twitter/X Workflow Items");

throw;
}
});
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Admin.Abstractions\OrchardCore.Admin.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.ContentManagement.Abstractions\OrchardCore.ContentManagement.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Data.Abstractions\OrchardCore.Data.Abstractions.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Data.YesSql\OrchardCore.Data.YesSql.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.DisplayManagement\OrchardCore.DisplayManagement.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Module.Targets\OrchardCore.Module.Targets.csproj" />
<ProjectReference Include="..\..\OrchardCore\OrchardCore.Navigation.Core\OrchardCore.Navigation.Core.csproj" />
Expand Down
3 changes: 3 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Http.Resilience;
using Microsoft.Extensions.Options;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement.Handlers;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using OrchardCore.Recipes;
using OrchardCore.Security.Permissions;
using OrchardCore.Settings;
using OrchardCore.Twitter.Drivers;
using OrchardCore.Twitter.Migrations;
using OrchardCore.Twitter.Recipes;
using OrchardCore.Twitter.Services;
using OrchardCore.Twitter.Settings;
Expand Down Expand Up @@ -62,6 +64,7 @@ public override void ConfigureServices(IServiceCollection services)
}
})
);
services.AddDataMigration<TwitterMigrations>();
}

public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Data.Migration;
davidpuplava marked this conversation as resolved.
Show resolved Hide resolved
using OrchardCore.Modules;
using OrchardCore.Twitter.Migrations;
using OrchardCore.Twitter.Workflows.Activities;
using OrchardCore.Twitter.Workflows.Drivers;
using OrchardCore.Workflows.Helpers;
Expand Down
Loading