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

Feature/1211 migrate device models from st table to database #1215

Merged

Conversation

hocinehacherouf
Copy link
Contributor

Description

What's new?

Remark : The column SensorDecoderURLin table DeviceTemplates won't be migrated. It is no more used by Portal and replaced by the column SensorDecoder

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other

@hocinehacherouf hocinehacherouf requested a review from a team as a code owner September 11, 2022 16:46
@codecov
Copy link

codecov bot commented Sep 11, 2022

Codecov Report

Base: 88.16% // Head: 87.94% // Decreases project coverage by -0.21% ⚠️

Coverage data is based on head (2088dd8) compared to base (8771382).
Patch coverage: 0.00% of modified lines in pull request are covered.

❗ Current head 2088dd8 differs from pull request most recent head 4f471b6. Consider uploading reports for the commit 4f471b6 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1215      +/-   ##
==========================================
- Coverage   88.16%   87.94%   -0.22%     
==========================================
  Files         211      213       +2     
  Lines        6927     6944      +17     
==========================================
  Hits         6107     6107              
- Misses        820      837      +17     
Impacted Files Coverage Δ
...c/AzureIoTHubPortal.Domain/Entities/DeviceModel.cs 0.00% <0.00%> (ø)
src/AzureIoTHubPortal.Domain/Entities/DeviceTag.cs 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines +22 to +51
foreach (var item in table.Query<TableEntity>().ToArray())
{
if (await set.AnyAsync(c => c.Id == item.RowKey))
continue;

#pragma warning disable CS8629 // Nullable value type may be null.
_ = await set.AddAsync(new DeviceModel
{
Id = item.RowKey,
Name = item[nameof(DeviceModel.Name)]?.ToString(),
Description = item[nameof(DeviceModel.Description)]?.ToString(),
IsBuiltin = bool.Parse(item[nameof(DeviceModel.IsBuiltin)]?.ToString() ?? "false"),
SupportLoRaFeatures = bool.Parse(item[nameof(DeviceModel.SupportLoRaFeatures)]?.ToString() ?? "false"),
ABPRelaxMode = bool.TryParse(item[nameof(DeviceModel.ABPRelaxMode)]?.ToString(), out var abpRelaxMode) ? abpRelaxMode : null,
Deduplication = Enum.TryParse<DeduplicationMode>(item[nameof(DeviceModel.Deduplication)]?.ToString(), out var deduplication) ? deduplication : null,
Downlink = bool.TryParse(item[nameof(DeviceModel.Downlink)]?.ToString(), out var downLink) ? downLink : null,
KeepAliveTimeout = int.TryParse(item[nameof(DeviceModel.KeepAliveTimeout)]?.ToString(), out var keepAliveTimeout) ? keepAliveTimeout : null,
PreferredWindow = int.TryParse(item[nameof(DeviceModel.PreferredWindow)]?.ToString(), out var preferredWindow) ? preferredWindow : null,
RXDelay = int.TryParse(item[nameof(DeviceModel.PreferredWindow)]?.ToString(), out var rxDelay) ? rxDelay : null,
UseOTAA = bool.TryParse(item[nameof(DeviceModel.UseOTAA)]?.ToString(), out var useOTAA) ? useOTAA : null,
AppEUI = item[nameof(DeviceModel.AppEUI)]?.ToString(),
SensorDecoder = item[nameof(DeviceModel.SensorDecoder)]?.ToString()
});
#pragma warning restore CS8629 // Nullable value type may be null.

if (config is ProductionConfigHandler)
{
_ = await table.DeleteEntityAsync(item.PartitionKey, item.RowKey);
}
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Where

This foreach loop implicitly filters its target sequence [here](1) - consider filtering the sequence explicitly using '.Where(...)'.
@kbeaugrand kbeaugrand force-pushed the feature/1211_migrate_device_models_from_st_table_to_database branch from 2088dd8 to 4f471b6 Compare September 11, 2022 17:15
@kbeaugrand kbeaugrand merged commit abd2b38 into main Sep 11, 2022
@kbeaugrand kbeaugrand deleted the feature/1211_migrate_device_models_from_st_table_to_database branch September 11, 2022 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate device models storage account table to database
2 participants