Skip to content

Commit

Permalink
Merge pull request #18 from marcduiker/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
marcduiker committed Apr 19, 2019
2 parents c2e7532 + 8d6b10f commit 4fed300
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public class GetLatestPublicationFromHistory
[StorageAccount(Configuration.ConnectionName)]
public async Task<Publication> Run(
[ActivityTrigger] PublicationConfiguration publicationConfiguration,
[Table(Configuration.Releases.TableName)] CloudTable table,
[Table(Configuration.Publications.TableName)] CloudTable table,
ILogger logger)
{
logger.LogInformation($"Started {nameof(GetLatestPublicationFromHistory)} for { publicationConfiguration.PublicationSourceOwner } { publicationConfiguration.PublicationSourceName }.");

Publication latestKnownPublication = null;
Publication latestKnownPublication = null;
var query = QueryBuilder<Publication>.CreateQueryForPartitionKey(publicationConfiguration.PublicationSourceName);
var queryResult = await table.ExecuteQuerySegmentedAsync(query, null);
latestKnownPublication = queryResult.Results.AsReadOnly().OrderByDescending(publication => publication.PublicationDate).FirstOrDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ public class GetLatestReleaseFromHistory
{
logger.LogInformation($"Started {nameof(GetLatestReleaseFromHistory)} for { repoConfiguration.RepositoryOwner } { repoConfiguration.RepositoryName }.");

RepositoryRelease latestKnownRelease = null;
RepositoryRelease latestKnownRelease = null;
var query = QueryBuilder<RepositoryRelease>.CreateQueryForPartitionKey(repoConfiguration.RepositoryName);
var queryResult = await table.ExecuteQuerySegmentedAsync(query, null);
latestKnownRelease = queryResult.Results.AsReadOnly().OrderByDescending(release => release.CreatedAt).FirstOrDefault();


if (latestKnownRelease != null)
{
logger.LogInformation($"Found release in history for configuration: {repoConfiguration.RepositoryName}, " +
$"Release ID: {latestKnownRelease.ReleaseId}," +
$"ReleaseCreatedAt: {latestKnownRelease.ReleaseCreatedAt:F}.");
}

return latestKnownRelease ?? new NullRelease(repoConfiguration.RepositoryName);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/AzureFunctionsUpdates/Storage/QueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ public static class QueryBuilder<T> where T : TableEntity, new()
{
public static TableQuery<T> CreateQueryForPartitionKey(string partitionKey)
{
var sanitizedPartitionKey = KeyFormatter.SanitizeKey(partitionKey);
return new TableQuery<T>()
.Where(GetFilterConditionWhichEqualsPartitionKey(partitionKey));
.Where(GetFilterConditionWhichEqualsPartitionKey(sanitizedPartitionKey));
}

private static string GetFilterConditionWhichEqualsPartitionKey(string partitionKey)
Expand Down

0 comments on commit 4fed300

Please sign in to comment.