Skip to content

Commit 0d0892d

Browse files
authored
Chore/cheaper azure sql (#34)
* chore: azure sql * fix: query filter * chore: update * fix: test
1 parent 5499c65 commit 0d0892d

File tree

13 files changed

+1153
-101
lines changed

13 files changed

+1153
-101
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test:
55
dotnet test ./tests/Evently.Server.Test/VisualPatron.Server.Test.csproj
66

77
add-migration:
8-
dotnet ef migrations add SQLServer --project=src/Evently.Server --context=AppDbContext --output-dir=Common/Adapters/Data/Migrations
8+
dotnet ef migrations add UpdateSeededDates --project=src/Evently.Server --context=AppDbContext --output-dir=Common/Adapters/Data/Migrations
99

1010
update-migration:
1111
dotnet ef database update --project=src/Evently.Server --context=AppDbContext

deploy/Terraform/.terraform.lock.hcl

Lines changed: 0 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/Terraform/billing-alert.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Budget for the resource group
2+
data "azurerm_client_config" "current" {}
3+
4+
resource "azurerm_consumption_budget_subscription" "evently_budget" {
5+
name = "budget-evently-dev"
6+
subscription_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}"
7+
8+
amount = 100 # 100 USD
9+
time_grain = "Monthly"
10+
11+
time_period {
12+
start_date = "2025-09-01T00:00:00Z"
13+
}
14+
15+
notification {
16+
enabled = true
17+
threshold = 80 // send notification when 80% reached
18+
operator = "GreaterThan"
19+
20+
contact_emails = [
21+
22+
]
23+
24+
contact_groups = []
25+
contact_roles = [
26+
"Owner",
27+
"Contributor"
28+
]
29+
}
30+
31+
notification {
32+
enabled = true
33+
threshold = 100
34+
operator = "GreaterThan"
35+
36+
contact_emails = [
37+
38+
]
39+
40+
contact_groups = []
41+
contact_roles = [
42+
"Owner",
43+
"Contributor"
44+
]
45+
}
46+
}

deploy/Terraform/container-app.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ resource "azurerm_container_app" "app" {
118118

119119
# Database Connection
120120
env {
121-
name = "ConnectionStrings__WebApiDatabase"
122-
value = local.sql_connection_string
121+
name = "ConnectionStrings__WebApiDatabase"
122+
secret_name = "sql-connection-string"
123123
}
124124

125125
# Storage Account Configuration
@@ -181,10 +181,10 @@ resource "azurerm_container_app" "app" {
181181
}
182182

183183
# Database connection string (from SQL database resource)
184-
# secret {
185-
# name = "sql-connection-string"
186-
# value = local.sql_connection_string
187-
# }
184+
secret {
185+
name = "sql-connection-string"
186+
value = local.sql_connection_string
187+
}
188188

189189
# Storage account connection string
190190
secret {

deploy/Terraform/main.tf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ terraform {
1313

1414
locals {
1515
environment = "staging"
16-
project_name = "evently"
1716
}
1817

19-
provider "docker" {}
20-
2118
provider "azurerm" {
2219
subscription_id = "e99ca647-4d2d-465f-b0a2-0b97d93c9024"
2320
features {}

deploy/Terraform/sql-database.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ resource "azurerm_mssql_server" "sql_server" {
1212
}
1313

1414
resource "azurerm_mssql_database" "db" {
15-
name = "evently"
16-
server_id = azurerm_mssql_server.sql_server.id
15+
name = "evently"
16+
server_id = azurerm_mssql_server.sql_server.id
17+
sku_name = "Basic" # Cheapest option: 5 DTUs
18+
max_size_gb = 2 # Minimum size for Basic tier
19+
auto_pause_delay_in_minutes = 60 # Auto-pause after 1 hour of inactivity
1720
}
1821

1922
resource "azurerm_mssql_firewall_rule" "allow_azure_services" {

src/Evently.Server/Common/Adapters/Data/AppDbContext.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -84,134 +84,134 @@ private static void SeedData(ModelBuilder modelBuilder) {
8484
Name = "Tech Innovation Summit",
8585
Description = "A comprehensive summit exploring the latest in AI and machine learning",
8686
Location = "Marina Bay Sands Convention Centre, Singapore",
87-
Start = new DateTimeOffset(year: 2025, month: 12, day: 5, hour: 9, minute: 0, second: 0, singaporeOffset),
88-
End = new DateTimeOffset(year: 2025, month: 12, day: 5, hour: 17, minute: 0, second: 0, singaporeOffset),
87+
Start = new DateTimeOffset(year: 2026, month: 12, day: 5, hour: 9, minute: 0, second: 0, singaporeOffset),
88+
End = new DateTimeOffset(year: 2026, month: 12, day: 5, hour: 17, minute: 0, second: 0, singaporeOffset),
8989
OrganiserId = hostUserId,
9090
},
9191
new Gathering {
9292
GatheringId = 2,
9393
Name = "Startup Networking Night",
9494
Description = "Connect with fellow entrepreneurs and investors",
9595
Location = "Clarke Quay Central, Singapore",
96-
Start = new DateTimeOffset(year: 2025, month: 12, day: 10, hour: 18, minute: 30, second: 0, singaporeOffset),
97-
End = new DateTimeOffset(year: 2025, month: 12, day: 10, hour: 22, minute: 0, second: 0, singaporeOffset),
96+
Start = new DateTimeOffset(year: 2026, month: 12, day: 10, hour: 18, minute: 30, second: 0, singaporeOffset),
97+
End = new DateTimeOffset(year: 2026, month: 12, day: 10, hour: 22, minute: 0, second: 0, singaporeOffset),
9898
OrganiserId = hostUserId,
9999
},
100100
new Gathering {
101101
GatheringId = 3,
102102
Name = "Digital Art Exhibition",
103103
Description = "Showcasing contemporary digital art from emerging artists",
104104
Location = "National Gallery Singapore",
105-
Start = new DateTimeOffset(year: 2025, month: 12, day: 15, hour: 10, minute: 0, second: 0, singaporeOffset),
106-
End = new DateTimeOffset(year: 2025, month: 12, day: 15, hour: 18, minute: 0, second: 0, singaporeOffset),
105+
Start = new DateTimeOffset(year: 2026, month: 12, day: 15, hour: 10, minute: 0, second: 0, singaporeOffset),
106+
End = new DateTimeOffset(year: 2026, month: 12, day: 15, hour: 18, minute: 0, second: 0, singaporeOffset),
107107
OrganiserId = hostUserId,
108108
},
109109
new Gathering {
110110
GatheringId = 4,
111111
Name = "Web Development Workshop",
112112
Description = "Learn modern web development techniques and best practices",
113113
Location = "Singapore Science Centre",
114-
Start = new DateTimeOffset(year: 2025, month: 12, day: 8, hour: 13, minute: 0, second: 0, singaporeOffset),
115-
End = new DateTimeOffset(year: 2025, month: 12, day: 8, hour: 17, minute: 0, second: 0, singaporeOffset),
114+
Start = new DateTimeOffset(year: 2026, month: 12, day: 8, hour: 13, minute: 0, second: 0, singaporeOffset),
115+
End = new DateTimeOffset(year: 2026, month: 12, day: 8, hour: 17, minute: 0, second: 0, singaporeOffset),
116116
OrganiserId = guestUserId,
117117
},
118118
new Gathering {
119119
GatheringId = 5,
120120
Name = "Business Strategy Seminar",
121121
Description = "Advanced strategies for scaling your business",
122122
Location = "Raffles City Convention Centre, Singapore",
123-
Start = new DateTimeOffset(year: 2025, month: 12, day: 20, hour: 14, minute: 0, second: 0, singaporeOffset),
124-
End = new DateTimeOffset(year: 2025, month: 12, day: 20, hour: 16, minute: 30, second: 0, singaporeOffset),
123+
Start = new DateTimeOffset(year: 2026, month: 12, day: 20, hour: 14, minute: 0, second: 0, singaporeOffset),
124+
End = new DateTimeOffset(year: 2026, month: 12, day: 20, hour: 16, minute: 30, second: 0, singaporeOffset),
125125
OrganiserId = guestUserId,
126126
},
127127
new Gathering {
128128
GatheringId = 6,
129129
Name = "Photography Masterclass",
130130
Description = "Professional photography techniques and portfolio building",
131131
Location = "Gardens by the Bay, Singapore",
132-
Start = new DateTimeOffset(year: 2025, month: 12, day: 22, hour: 8, minute: 0, second: 0, singaporeOffset),
133-
End = new DateTimeOffset(year: 2025, month: 12, day: 22, hour: 12, minute: 0, second: 0, singaporeOffset),
132+
Start = new DateTimeOffset(year: 2026, month: 12, day: 22, hour: 8, minute: 0, second: 0, singaporeOffset),
133+
End = new DateTimeOffset(year: 2026, month: 12, day: 22, hour: 12, minute: 0, second: 0, singaporeOffset),
134134
OrganiserId = guestUserId,
135135
},
136136
new Gathering {
137137
GatheringId = 7,
138138
Name = "Mobile App Development Bootcamp",
139139
Description = "Intensive bootcamp covering iOS and Android development",
140140
Location = "NUS School of Computing, Singapore",
141-
Start = new DateTimeOffset(year: 2025, month: 12, day: 12, hour: 9, minute: 0, second: 0, singaporeOffset),
142-
End = new DateTimeOffset(year: 2025, month: 12, day: 12, hour: 18, minute: 0, second: 0, singaporeOffset),
141+
Start = new DateTimeOffset(year: 2026, month: 12, day: 12, hour: 9, minute: 0, second: 0, singaporeOffset),
142+
End = new DateTimeOffset(year: 2026, month: 12, day: 12, hour: 18, minute: 0, second: 0, singaporeOffset),
143143
OrganiserId = hostUserId,
144144
},
145145
new Gathering {
146146
GatheringId = 8,
147147
Name = "Investment & Finance Forum",
148148
Description = "Learn about personal finance and investment strategies",
149149
Location = "Suntec Singapore Convention Centre",
150-
Start = new DateTimeOffset(year: 2025, month: 12, day: 25, hour: 14, minute: 0, second: 0, singaporeOffset),
151-
End = new DateTimeOffset(year: 2025, month: 12, day: 25, hour: 17, minute: 30, second: 0, singaporeOffset),
150+
Start = new DateTimeOffset(year: 2026, month: 12, day: 25, hour: 14, minute: 0, second: 0, singaporeOffset),
151+
End = new DateTimeOffset(year: 2026, month: 12, day: 25, hour: 17, minute: 30, second: 0, singaporeOffset),
152152
OrganiserId = hostUserId,
153153
},
154154
new Gathering {
155155
GatheringId = 9,
156156
Name = "Creative Writing Workshop",
157157
Description = "Explore storytelling techniques and creative expression",
158158
Location = "Esplanade Theatres, Singapore",
159-
Start = new DateTimeOffset(year: 2025, month: 12, day: 28, hour: 10, minute: 0, second: 0, singaporeOffset),
160-
End = new DateTimeOffset(year: 2025, month: 12, day: 28, hour: 15, minute: 0, second: 0, singaporeOffset),
159+
Start = new DateTimeOffset(year: 2026, month: 12, day: 28, hour: 10, minute: 0, second: 0, singaporeOffset),
160+
End = new DateTimeOffset(year: 2026, month: 12, day: 28, hour: 15, minute: 0, second: 0, singaporeOffset),
161161
OrganiserId = guestUserId,
162162
},
163163
new Gathering {
164164
GatheringId = 10,
165165
Name = "Cloud Computing Conference",
166166
Description = "Latest trends in cloud architecture and DevOps",
167167
Location = "Singapore EXPO",
168-
Start = new DateTimeOffset(year: 2025, month: 12, day: 30, hour: 9, minute: 30, second: 0, singaporeOffset),
169-
End = new DateTimeOffset(year: 2025, month: 12, day: 30, hour: 17, minute: 30, second: 0, singaporeOffset),
168+
Start = new DateTimeOffset(year: 2026, month: 12, day: 30, hour: 9, minute: 30, second: 0, singaporeOffset),
169+
End = new DateTimeOffset(year: 2026, month: 12, day: 30, hour: 17, minute: 30, second: 0, singaporeOffset),
170170
OrganiserId = hostUserId,
171171
},
172172
new Gathering {
173173
GatheringId = 11,
174174
Name = "E-commerce Mastery",
175175
Description = "Build and scale your online business effectively",
176176
Location = "Marina Bay Financial Centre, Singapore",
177-
Start = new DateTimeOffset(year: 2026, month: 1, day: 3, hour: 13, minute: 0, second: 0, singaporeOffset),
178-
End = new DateTimeOffset(year: 2026, month: 1, day: 3, hour: 18, minute: 0, second: 0, singaporeOffset),
177+
Start = new DateTimeOffset(year: 2027, month: 1, day: 3, hour: 13, minute: 0, second: 0, singaporeOffset),
178+
End = new DateTimeOffset(year: 2027, month: 1, day: 3, hour: 18, minute: 0, second: 0, singaporeOffset),
179179
OrganiserId = guestUserId,
180180
},
181181
new Gathering {
182182
GatheringId = 12,
183183
Name = "Contemporary Dance Performance",
184184
Description = "An evening of modern dance and artistic expression",
185185
Location = "Victoria Theatre, Singapore",
186-
Start = new DateTimeOffset(year: 2026, month: 1, day: 5, hour: 19, minute: 30, second: 0, singaporeOffset),
187-
End = new DateTimeOffset(year: 2026, month: 1, day: 5, hour: 22, minute: 0, second: 0, singaporeOffset),
186+
Start = new DateTimeOffset(year: 2027, month: 1, day: 5, hour: 19, minute: 30, second: 0, singaporeOffset),
187+
End = new DateTimeOffset(year: 2027, month: 1, day: 5, hour: 22, minute: 0, second: 0, singaporeOffset),
188188
OrganiserId = hostUserId,
189189
},
190190
new Gathering {
191191
GatheringId = 13,
192192
Name = "Cybersecurity Awareness Training",
193193
Description = "Essential cybersecurity practices for businesses",
194194
Location = "Singapore Management University",
195-
Start = new DateTimeOffset(year: 2026, month: 1, day: 8, hour: 10, minute: 0, second: 0, singaporeOffset),
196-
End = new DateTimeOffset(year: 2026, month: 1, day: 8, hour: 16, minute: 0, second: 0, singaporeOffset),
195+
Start = new DateTimeOffset(year: 2027, month: 1, day: 8, hour: 10, minute: 0, second: 0, singaporeOffset),
196+
End = new DateTimeOffset(year: 2027, month: 1, day: 8, hour: 16, minute: 0, second: 0, singaporeOffset),
197197
OrganiserId = guestUserId,
198198
},
199199
new Gathering {
200200
GatheringId = 14,
201201
Name = "Leadership Excellence Workshop",
202202
Description = "Develop essential leadership skills for modern managers",
203203
Location = "Orchard Hotel Singapore",
204-
Start = new DateTimeOffset(year: 2026, month: 1, day: 10, hour: 9, minute: 0, second: 0, singaporeOffset),
205-
End = new DateTimeOffset(year: 2026, month: 1, day: 10, hour: 17, minute: 0, second: 0, singaporeOffset),
204+
Start = new DateTimeOffset(year: 2027, month: 1, day: 10, hour: 9, minute: 0, second: 0, singaporeOffset),
205+
End = new DateTimeOffset(year: 2027, month: 1, day: 10, hour: 17, minute: 0, second: 0, singaporeOffset),
206206
OrganiserId = hostUserId,
207207
},
208208
new Gathering {
209209
GatheringId = 15,
210210
Name = "Film & Media Production Showcase",
211211
Description = "Independent filmmakers present their latest works",
212212
Location = "Singapore International Film Festival Venue",
213-
Start = new DateTimeOffset(year: 2026, month: 1, day: 12, hour: 18, minute: 0, second: 0, singaporeOffset),
214-
End = new DateTimeOffset(year: 2026, month: 1, day: 12, hour: 23, minute: 0, second: 0, singaporeOffset),
213+
Start = new DateTimeOffset(year: 2027, month: 1, day: 12, hour: 18, minute: 0, second: 0, singaporeOffset),
214+
End = new DateTimeOffset(year: 2027, month: 1, day: 12, hour: 23, minute: 0, second: 0, singaporeOffset),
215215
OrganiserId = guestUserId,
216216
}
217217
);
@@ -237,7 +237,7 @@ private static void SeedData(ModelBuilder modelBuilder) {
237237

238238
// Seed Bookings with fixed DateTimeOffset values
239239
// Fixed DateTimeOffset for seeding (static value)
240-
DateTimeOffset fixedCreationTime = new(year: 2024, month: 1, day: 1, hour: 0, minute: 0, second: 0, TimeSpan.Zero);
240+
DateTimeOffset fixedCreationTime = new(year: 2025, month: 1, day: 1, hour: 0, minute: 0, second: 0, TimeSpan.Zero);
241241

242242
modelBuilder.Entity<Booking>().HasData(
243243
new Booking {

0 commit comments

Comments
 (0)