Exemplo n.º 1
0
        private async Task <(string Uuid, string CommitHash)[]> GetUuidsByFirmIdAsync(long[] firmids)
        {
            var moderationUri = _amsBaseUri + $"/moderation?limit={_options.BatchSize}&firm_id={PrepareUrlParameterValue(firmids)}&state={PrepareUrlParameterValue(_statusesForMigration)}";

            using (var response = await _retryPolicy.ExecuteAsync(() => _httpClient.GetAsync(moderationUri)))
            {
                if (response.StatusCode == HttpStatusCode.NotFound)
                {
                    _logger.Warning("[EMPTY_FIRM] Am data not found for firms: {firms}", string.Join(",", firmids));
                    return(null);
                }
                response.EnsureSuccessStatusCode();
                var json = await response.Content.ReadAsStringAsync();

                var result = Amsv1Response.FromJson(json);

                var foundMaterialFirmIds = result.Result.Items.Select(i => long.Parse(i.FirmId));
                _logger.Warning("[EMPTY_FIRM] Am data not found for firms: {firms}", string.Join(",", firmids.Except(foundMaterialFirmIds)));

                foreach (var item in result.Result.Items)
                {
                    if (!_statusesForMigration.Contains(item.State))
                    {
                        _logger.Warning("[UNACCEPTABLE_STATUS] AM with id {uuid} wouldn't be processed due unacceptable moderation status {state}.", item.Uuid, item.State);
                    }
                }

                var uuids = result.Result.Items
                            .Where(i => _statusesForMigration.Contains(i.State))
                            .Select(i => (i.Uuid, i.Commit))
                            .ToArray();

                return(uuids);
            }
        }
Exemplo n.º 2
0
        private async Task <(string Uuid, string CommitHash)> GetUuidByFirmIdAsync(long firmid)
        {
            var uri = _amsBaseUri + $"/moderation?firm_id={firmid}&state={PrepareUrlParameterValue(_statusesForMigration)}";

            using (var response = await _retryPolicy.ExecuteAsync(() => _httpClient.GetAsync(uri)))
            {
                if (response.StatusCode == HttpStatusCode.NotFound)
                {
                    return(null, null);
                }
                response.EnsureSuccessStatusCode();

                var json = await response.Content.ReadAsStringAsync();

                var result = Amsv1Response.FromJson(json);

                var item = result.Result.Items.First();

                if (!_statusesForMigration.Contains(item.State))
                {
                    _logger.Warning("[UNACCEPTABLE_STATUS] AM with id {uuid} wouldn't be processed due unacceptable moderation status {state}.", item.Uuid, item.State);
                    return(null, null);
                }

                return(item.Uuid, item.Commit);
            }
        }