Firebase-database: Structure for event application with data consistency - json

As many have before me, I am building an event app using Firebase as the database.
After watching this https://www.youtube.com/watch?v=i1n9Kw3AORw I think that my current data structure is wrong so I want to change it.
This is something that I hope will keep track of which events users have been to, their responses, check ins and help update user information like in the video.
{
"events": {
"event1": {
"title": "Event 1",
"venue": {
"venue1": true
},
"guests": {
"user1": true,
"user2": true
}
},
"event2": {}
},
"locationHistory": {
"location1": {
"user1": true,
"user2": true
},
"location2": {
"user3": true
}
},
"userCheckIns": {
"event1": {
"user1": true
}
},
"userResponses": { // not sure about these responses
"event1": {
"user1": true,
"user2": false,
"user3": "maybe"
},
"event2": {}
},
"eventGuests": {
"event1": {
"user1": {
"name": "user name 1"
},
"user2": {
"name": "user name 2"
}
},
"event2": {}
},
"userEvents": {
"user1": {
"event1": true
},
"user2": {
"event1": true
}
},
"venues": {
"venue1": {
"name": "Venue name",
"location": "location1"
},
"users": {
"user1": {
"name": "user name 1",
"events": {
"event1": true
}
},
"user2": {
"name": "user name 2",
"events": {
"event1": true
}
}
}
}
}

Related

How Should the Json Output Look in Nlog?

I am using nlog json layout and took this from the example
{
"Logging": {
"NLog": {
"IncludeScopes": false,
"ParseMessageTemplates": true,
"CaptureMessageProperties": true
}
},
"NLog": {
"autoreload": true,
"internalLogLevel": "Info",
"internalLogFile": "c:/temp/console-example-internal2.log",
"throwConfigExceptions": true,
"targets": {
"console": {
"type": "Console",
"layout": "${date}|${level:uppercase=true}|${message} ${exception:format=tostring}|${logger}|${all-event-properties}"
},
"file": {
"type": "AsyncWrapper",
"target": {
"wrappedFile": {
"type": "File",
"fileName": "c:/temp/console-example2.log",
"layout": {
"type": "JsonLayout",
"Attributes": [
{ "name": "timestamp", "layout": "${date:format=o}" },
{ "name": "level", "layout": "${level}" },
{ "name": "logger", "layout": "${logger}" },
{ "name": "message", "layout": "${message:raw=true}" },
{ "name": "properties", "encode": false, "layout": { "type": "JsonLayout", "includeallproperties": "true" } }
]
}
}
}
}
},
"rules": [
{
"logger": "*",
"minLevel": "Trace",
"writeTo": "File,Console"
}
]
}
}
https://github.com/NLog/NLog.Extensions.Logging/blob/master/examples/NetCore2/ConsoleExampleJsonConfig/appsettings.json
on this line I saw this { "name": "message", "layout": "${message:raw=true}" } I changed it to false.
when I do this
var test = "Something";
logger.Info("This is what is stored in the variable: {var}", test);
I get
{
"message": This is what is stored in the variable: \"Something\""
}
Why is it in quotes?
When I change raw to "true" I get
{
"message": This is what is stored in the variable: {test}"
}
how do I just get "This is what is stored in the variable: Something"

Card_V2 display issue in Google Chat

I have the following JSON to display Card_V2 for Google Chat, (note: words with "let_" are variables):
{
"cards_v2": [
{
"card": {
"header": {
"title": "Create campaign",
"subtitle": "Please complete the following information",
"imageType": "CIRCLE",
"imageUrl": "let_avatar"
},
"sections": [
{
"widgets": [
{
"textInput": {
"label": "Campaign name",
"type": "SINGLE_LINE",
"name": "nCampaign",
"value": "let_campaign"
}
},
{
"textInput": {
"label": "Campaign subject",
"type": "SINGLE_LINE",
"name": "subject",
"value": "let_subject"
}
},
{
"textInput": {
"label": "User name",
"type": "SINGLE_LINE",
"name": "userName",
"value": "let_userName"
}
},
{
"buttonList": {
"buttons": [
{
"text": "Create campaign",
"color": {
"red": 0.502,
"green": 1,
"blue": 0.733,
"alpha": 1
},
"onClick": {
"action": {
"function": "create",
"parameters": []
}
}
},
{
"text": "Cancel",
"color": {
"red": 0.502,
"green": 1,
"blue": 0.733,
"alpha": 1
},
"onClick": {
"action": {
"function": "cancel",
"parameters": []
}
}
}
]
},
"horizontalAlignment": "CENTER"
}
]
}
]
}
}
]
}
My problem is that the "textInput" screen does not appear, but last week it did. Does anyone have any idea what's going on?
PS: the Card is the return of the onMessage(event) function in Google Apps Script

How to store parameters correctly in a mongodb document?

I am looking for a way to store my application settings and I would like to do it in a clear and optimized way. I hesitate between these two ways or if you have another way do not hesitate to tell me
{
"_id": {
"$oid": "62d01540f5c83dd3cf40113f"
},
"server_id": "989984533623480410",
"plugins": {
"welcome": {
"enabled": false,
"settings": {
"send-new-message": true
}
},
"moderation": {
"enabled": false,
"settings": {
"param-1": true
}
}
}
}
and
{
"_id": {
"$oid": "62d01540f5c83dd3cf40113f"
},
"server_id": "989984533623480410",
"plugins": {
"welcome": {
"enabled": false
},
"moderation": {
"enabled": false
}
},
"settings": {
"plugins": {
"moderation": {
"send-new-message": true
},
"welcome": {
"param-1": true
}
}
}
}

JSON formatting for Terraform API

I am trying to create a JSON file that will add env variables to a TFE workspace via API.. I am new to JSON so bear with me.. below is what I am trying to use but I can’t seem to get the brackets or formatting correct.. can someone help me out?
{
"data": {
"type":"vars",
"attributes": {
"key":"ID1",
"value":"xxxxxx",
"description":"",
"category":"terraform",
"hcl":false,
"sensitive":false
}
}
"data": {
"type":"vars",
"attributes": {
"key":"ID2",
"value":"xxxxxx",
"description":"",
"category":"terraform",
"hcl":false,
"sensitive":false
}
}
"data": {
"type":"vars",
"attributes": {
"key":"ID3",
"value":"xxxxxx",
"description":"",
"category":"terraform",
"hcl":false,
"sensitive":true
}
}
"data": {
"type":"vars",
"attributes": {
"key":"ID4",
"value":"xxxxxx",
"description":"",
"category":"terraform",
"hcl":false,
"sensitive":true
}
}
}
The following is a valid JSON payload:
{
"data": [
{
"type": "vars",
"attributes": {
"key": "ID1",
"value": "xxxxxx",
"description": "",
"category": "terraform",
"hcl": false,
"sensitive": false
}
},
{
"type": "vars",
"attributes": {
"key": "ID2",
"value": "xxxxxx",
"description": "",
"category": "terraform",
"hcl": false,
"sensitive": false
}
},
{
"type": "vars",
"attributes": {
"key": "ID3",
"value": "xxxxxx",
"description": "",
"category": "terraform",
"hcl": false,
"sensitive": true
}
},
{
"type": "vars",
"attributes": {
"key": "ID4",
"value": "xxxxxx",
"description": "",
"category": "terraform",
"hcl": false,
"sensitive": true
}
}
]
}

How to echo user select optionset from ChoiceSet using messageBack or imBack?

I am trying to echo the user selected option from given set of user rating drop down using messageBack or imBack (whichever is possible). Since, I am only able to add a static text as value in messageBack value field
"actions": [
{
"type": "Action.Submit",
"title": "OK",
"data": {
"msteams": {
"type": "imBack",
"value": "User selected option"
}
}
}
]
Is there a way that I can get the value from choiceset and show is using messageBack on MS Teams?
You can refer to complete JSON here:
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"color": "Accent",
"text": "Rate your experience!"
},
{
"type": "TextBlock",
"separator": true,
"text": "Please rate your experience! Your feedback is very appreciated and will help improve your experience in the future. ",
"wrap": true
},
{
"type": "Input.ChoiceSet",
"id": "CompactSelect",
"label": "What color do you want? (compact)",
"style": "compact",
"isRequired": true,
"errorMessage": "This is a required input",
"placeholder": "Please choose",
"choices": [
{
"title": "⭐⭐⭐⭐⭐",
"value": "⭐⭐⭐⭐⭐"
},
{
"title": "⭐⭐⭐⭐",
"value": "⭐⭐⭐⭐"
},
{
"title": "⭐⭐⭐",
"value": "⭐⭐⭐"
},
{
"title": "⭐⭐",
"value": "⭐⭐"
},
{
"title": "⭐",
"value": "⭐"
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK",
"data": {
"msteams": {
"type": "imBack",
"value": "User selected option"
}
}
}
]
}
#user30 - Could you please check this Code?
var InputChoices = new List<AdaptiveChoice> {
new AdaptiveChoice() { Title = "Red",
Value = "Red" },
new AdaptiveChoice() { Title = "Green",
Value = "Green" },
new AdaptiveChoice() { Title = "White",
Value = "White" },
new AdaptiveChoice() { Title = "Black",
Value = "Black" }
};
return new AdaptiveCard()
{
Body = new List<AdaptiveElement>()
{
new AdaptiveColumnSet()
{
Columns=new List<AdaptiveColumn>()
{
new AdaptiveColumn()
{
Items=new List<AdaptiveElement>()
{
new AdaptiveTextBlock()
{
Text="Colors",
Id="colorCodeId",
Spacing=AdaptiveSpacing.None,
Wrap=true
}
}
},
new AdaptiveColumn()
{
Items=new List<AdaptiveElement>()
{
new AdaptiveChoiceSetInput()
{
Id="colorCodeId",
Spacing=AdaptiveSpacing.None,
Choices=new List<AdaptiveChoice>(InputChoices),
Style=AdaptiveChoiceInputStyle.Compact
}
}
}
}
},
},
Actions = new List<AdaptiveAction>()
{
new AdaptiveSubmitAction
{
Type = AdaptiveSubmitAction.TypeName,
Title = "Submit"
},
},
}