|
1 |
| -using Gremlin.Net.Driver; |
2 |
| -using Gremlin.Net.Structure.IO.GraphSON; |
3 | 1 | using Microsoft.AspNetCore.Mvc;
|
4 | 2 | using Microsoft.Azure.Documents;
|
5 | 3 | using Microsoft.Azure.Documents.Client;
|
@@ -55,8 +53,6 @@ public static async Task RunPetChecker(
|
55 | 53 | doc.Message = message;
|
56 | 54 | log.Info($"--- Updating CosmosDb document to have historical data");
|
57 | 55 | await UpsertDocument(doc, log);
|
58 |
| - log.Info($"--- Updating Graph"); |
59 |
| - await InsertInGraph(tags, doc, log); |
60 | 56 | log.Info("--- Sending SignalR response.");
|
61 | 57 | sendingResponse = true;
|
62 | 58 | await SendSignalRResponse(sender, allowed, message);
|
@@ -99,61 +95,6 @@ private static Task SendSignalRResponse(IAsyncCollector<SignalRMessage> sender,
|
99 | 95 |
|
100 | 96 | }
|
101 | 97 |
|
102 |
| - private static async Task InsertInGraph(IEnumerable<string> tags, dynamic doc, TraceWriter log) |
103 |
| - { |
104 |
| - var hostname = await GetSecret("gremlin_endpoint"); |
105 |
| - var port = await GetSecret("gremlin_port"); |
106 |
| - var database = "pets"; |
107 |
| - var collection = "checks"; |
108 |
| - var authKey = Environment.GetEnvironmentVariable("gremlin_key"); |
109 |
| - var portToUse = 443; |
110 |
| - portToUse = int.TryParse(port, out portToUse) ? portToUse : 443; |
111 |
| - |
112 |
| - var gremlinServer = new GremlinServer(hostname, portToUse, enableSsl: true, |
113 |
| - username: "/dbs/" + database + "/colls/" + collection, |
114 |
| - password: authKey); |
115 |
| - var gremlinClient = new GremlinClient(gremlinServer, new GraphSON2Reader(), new GraphSON2Writer(), GremlinClient.GraphSON2MimeType); |
116 |
| - foreach (var tag in tags) |
117 |
| - { |
118 |
| - log.Info("--- --- Checking vertex for tag " + tag); |
119 |
| - await TryAddTag(gremlinClient, tag, log); |
120 |
| - } |
121 |
| - |
122 |
| - var queries = AddPetToGraphQueries(doc, tags); |
123 |
| - log.Info("--- --- Adding vertex for pet checkin "); |
124 |
| - foreach (string query in queries) |
125 |
| - { |
126 |
| - await gremlinClient.SubmitAsync<dynamic>(query); |
127 |
| - } |
128 |
| - } |
129 |
| - |
130 |
| - private static async Task TryAddTag(GremlinClient gremlinClient, string tag, TraceWriter log) |
131 |
| - { |
132 |
| - var query = $"g.V('{tag}')"; |
133 |
| - var response = await gremlinClient.SubmitAsync<dynamic>(query); |
134 |
| - |
135 |
| - if (!response.Any()) |
136 |
| - { |
137 |
| - log.Info("--- --- Adding vertex for tag " + tag); |
138 |
| - await gremlinClient.SubmitAsync<dynamic>(AddTagToGraphQuery(tag)); |
139 |
| - } |
140 |
| - } |
141 |
| - |
142 |
| - private static IEnumerable<string> AddPetToGraphQueries(dynamic doc, IEnumerable<string> tags) |
143 |
| - { |
144 |
| - var id = doc.id.ToString(); |
145 |
| - |
146 |
| - var msg = (doc.Message?.ToString() ?? "").Replace("'", "\'"); |
147 |
| - |
148 |
| - yield return $"g.addV('checkin').property('id','{id}').property('description','{msg}')"; |
149 |
| - foreach (var tag in tags) |
150 |
| - { |
151 |
| - yield return $"g.V('{id}').addE('seems').to(g.V('{tag}'))"; |
152 |
| - } |
153 |
| - } |
154 |
| - |
155 |
| - private static string AddTagToGraphQuery(string tag) => $"g.addV('tag').property('id', '{tag}').property('value', '{tag}')"; |
156 |
| - |
157 | 98 | private static async Task UpsertDocument(dynamic doc, TraceWriter log)
|
158 | 99 | {
|
159 | 100 | var endpoint = await GetSecret("cosmos_uri");
|
|
0 commit comments