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/md7319/cosmosdbusage main #125

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

md7319
Copy link
Collaborator

@md7319 md7319 commented Sep 20, 2024

Added logic to use Cosmos DB as storage for OrcanodeMonitor data .

@dthaler
Copy link
Collaborator

dthaler commented Sep 20, 2024

Fixes #106

@@ -105,6 +109,7 @@ private static Orcanode FindOrCreateOrcanodeByDataplicitySerial(DbSet<Orcanode>
connectionStatus = OrcanodeOnlineStatus.Absent;
Orcanode newNode = CreateOrcanode(nodeList);
newNode.DataplicitySerial = serial;
newNode.year= DateTime.UtcNow.Year.ToString();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orcanodes should not have a year, only events.

@@ -430,7 +436,7 @@ public async static Task UpdateOrcasoundDataAsync(OrcanodeMonitorContext context
}

// Create a list to track what nodes are no longer returned.
var unfoundList = context.Orcanodes.ToList();
var unfoundList = context.Orcanodes!=null ?context.Orcanodes.ToList():null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var unfoundList = context.Orcanodes!=null ?context.Orcanodes.ToList():null;
var unfoundList = context.Orcanodes?.ToList();

@@ -542,6 +549,31 @@ public async static Task UpdateOrcasoundDataAsync(OrcanodeMonitorContext context
{
node.OrcasoundVisible = visible.GetBoolean();
}
/* if (attributes.TryGetProperty("bucket_region", out var bucketregion))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't have commented out code

modelBuilder.Entity<Orcanode>()
.ToContainer("Orcanode")
.Property(item => item.ID);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

.WithMany()
.HasForeignKey(item=>item.OrcanodeId);

/*modelBuilder.Entity<OrcanodeEvent>()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't have commented out code

@@ -69,6 +69,7 @@ public OrcanodeEvent(Orcanode node, string type, string value, DateTime timestam
Value = value;
DateTimeUtc = timestamp;
OrcanodeId = node.ID;
year = DateTime.UtcNow.Year.ToString();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
year = DateTime.UtcNow.Year.ToString();
Year = DateTime.UtcNow.Year.ToString();

capitalize for consistency with the existing fields


// Navigation property that uses OrcanodeId.
public virtual Orcanode Orcanode { get; set; }

public DateTime DateTimeUtc { get; set; }

public string year { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public string year { get; set; }
public string Year { get; set; }

Can this be an integer or must it be a string?
And if this is a partition key, add a comment saying so.

@@ -6,6 +6,7 @@
using System.Text.Json.Serialization;
using System.Xml.Linq;
using Microsoft.IdentityModel.Tokens;
using Microsoft.VisualBasic;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is VisualBasic needed for?

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert adding this file.
.user" files should not be checked in.
(I will add that suffix to .gitignore.)


var builder = WebApplication.CreateBuilder(args);

// First see if an environment variable specifies a connection string.
var connection = Environment.GetEnvironmentVariable("AZURE_SQL_CONNECTIONSTRING");
//var connection = Environment.GetEnvironmentVariable("AZURE_SQL_CONNECTIONSTRING");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not have commented out code

@dthaler
Copy link
Collaborator

dthaler commented Sep 20, 2024

@md7319 this is great progress, thanks! see comments, mostly stylistic.

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.

2 participants