Skip to content

Commit

Permalink
Merge tag 'universe-1.3.1' into dev
Browse files Browse the repository at this point in the history
universe-1.3.1
  • Loading branch information
kuromukira committed Oct 11, 2022
2 parents 86b54f9 + a1cb443 commit 324799a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/nuget-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ jobs:
run: |
cd ./code
dotnet build --no-restore
# Pack
- name: Pack
run: dotnet pack code/Universe/UniverseQuery.csproj -c Release

# Publish new version
# Publish
- name: Publish
uses: brandedoutcast/publish-nuget@v2
with:
PROJECT_FILE_PATH: code/Universe/UniverseQuery.csproj
TAG_COMMIT: false
VERSION_FILE_PATH: VERSION
NUGET_KEY: ${{secrets.NUGET_KEY}}
PACKAGE_NAME: UniverseQuery
run: dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_KEY}} --skip-duplicate
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<Version>1.3.0</Version>
<Version>1.3.1</Version>
18 changes: 12 additions & 6 deletions code/Universe/Galaxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,37 @@ protected Galaxy(Database db, string container, string partitionKey, bool record
private static QueryDefinition CreateQuery(IList<Catalyst> catalysts, ColumnOptions? columnOptions = null, IList<Sorting.Option> sorting = null, IList<string> groups = null)
{
// Column Options Builder
string columnsBuilder = "*";
StringBuilder columnsBuilder = new("*");
if (columnOptions is not null)
{
columnsBuilder = string.Join(", ", columnOptions?.Names.Select(c => $"c.{c}").ToList());
if (columnOptions?.Names is not null && columnOptions?.Names.Count > 0)
columnsBuilder.Append(string.Join(", ", columnOptions?.Names.Select(c => $"c.{c}").ToList()));

if ((columnOptions?.Top ?? 0) > 0)
columnsBuilder = $"TOP {columnOptions?.Top ?? 1} {columnsBuilder}";
columnsBuilder.Append($"TOP {columnOptions?.Top ?? 1} {columnsBuilder}");

if (columnOptions?.IsDistinct ?? false)
columnsBuilder = $"DISTINCT {columnsBuilder}";
columnsBuilder.Append($"DISTINCT {columnsBuilder}");

if (columnOptions?.Count ?? false)
{
groups ??= new List<string>();
groups = groups.Concat(columnOptions?.Names ?? new List<string>()).Distinct().ToList();
columnsBuilder = $"{columnsBuilder}, COUNT(1) Count";
columnsBuilder.Append($"{columnsBuilder}, COUNT(1) Count");
}
}

// This error blocks code execution since this is not yet supported by CosmosDb
if (sorting is not null && sorting.Any() && groups is not null && groups.Any())
throw new UniverseException("ORDER BY is not supported in presence of GROUP BY");

// Update Columns Builder with Group By
string columnsInQuery = columnsBuilder.ToString();
if (columnsInQuery.Contains("*") && groups is not null && groups.Any())
columnsInQuery.Replace("*", string.Join(", ", groups.Select(c => $"c.{c}").ToList()));

// Where Clause Builder
StringBuilder queryBuilder = new($"SELECT {columnsBuilder} FROM c");
StringBuilder queryBuilder = new($"SELECT {columnsInQuery} FROM c");
if (catalysts.Any())
{
queryBuilder.Append($" WHERE {WhereClauseBuilder(catalysts[0])}");
Expand Down
6 changes: 3 additions & 3 deletions code/Universe/UniverseQuery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
<RepositoryType>Git</RepositoryType>
<Authors>Nor Gelera</Authors>
<Product>Universe</Product>
<Version>1.3.0</Version>
<Version>1.3.1</Version>
<PackageReleaseNotes>View release on https://github.com/kuromukira/universe/releases</PackageReleaseNotes>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<FileVersion>1.3.0.0</FileVersion>
<AssemblyVersion>1.3.1.0</AssemblyVersion>
<FileVersion>1.3.1.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand Down

0 comments on commit 324799a

Please sign in to comment.