-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:Squidex/squidex
- Loading branch information
Showing
59 changed files
with
1,880 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ jobs: | |
uses: actions/[email protected] | ||
|
||
- name: Prepare - Inject short Variables | ||
uses: rlespinasse/github-slug-action@v4.5.0 | ||
uses: rlespinasse/github-slug-action@v5.0.0 | ||
|
||
- name: Prepare - Setup QEMU | ||
uses: docker/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ jobs: | |
uses: actions/[email protected] | ||
|
||
- name: Prepare - Inject short Variables | ||
uses: rlespinasse/github-slug-action@v4.5.0 | ||
uses: rlespinasse/github-slug-action@v5.0.0 | ||
|
||
- name: Prepare - Setup QEMU | ||
uses: docker/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/IndexParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// ========================================================================== | ||
// Squidex Headless CMS | ||
// ========================================================================== | ||
// Copyright (c) Squidex UG (haftungsbeschraenkt) | ||
// All rights reserved. Licensed under the MIT license. | ||
// ========================================================================== | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using MongoDB.Bson; | ||
using Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations; | ||
using Squidex.Infrastructure.Queries; | ||
using Squidex.Infrastructure.States; | ||
|
||
namespace Squidex.Domain.Apps.Entities.MongoDb.Contents; | ||
|
||
public static class IndexParser | ||
{ | ||
public static bool TryParse(BsonDocument source, string prefix, [MaybeNullWhen(false)] out IndexDefinition index) | ||
{ | ||
index = null!; | ||
|
||
if (!source.TryGetValue("name", out var name) || name.BsonType != BsonType.String) | ||
{ | ||
return false; | ||
} | ||
|
||
if (!name.AsString.StartsWith(prefix, StringComparison.Ordinal)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (!source.TryGetValue("key", out var keys) || keys.BsonType != BsonType.Document) | ||
{ | ||
return false; | ||
} | ||
|
||
var definition = new IndexDefinition(); | ||
foreach (var property in keys.AsBsonDocument) | ||
{ | ||
if (property.Value.BsonType != BsonType.Int32) | ||
{ | ||
return false; | ||
} | ||
|
||
var fieldName = Adapt.MapPathReverse(property.Name).ToString(); | ||
|
||
var order = property.Value.AsInt32 < 0 ? | ||
SortOrder.Descending : | ||
SortOrder.Ascending; | ||
|
||
definition.Add(new IndexField(fieldName, order)); | ||
} | ||
|
||
if (definition.Count == 0) | ||
{ | ||
return false; | ||
} | ||
|
||
index = definition; | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.