Migration to add actual production data of 2025 season
This commit is contained in:
17
Cargo.lock
generated
17
Cargo.lock
generated
@@ -19,6 +19,21 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "actix-cors"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "daa239b93927be1ff123eebada5a3ff23e89f0124ccb8609234e5103d5a5ae6d"
|
||||||
|
dependencies = [
|
||||||
|
"actix-utils",
|
||||||
|
"actix-web",
|
||||||
|
"derive_more",
|
||||||
|
"futures-util",
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
"smallvec",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "actix-http"
|
name = "actix-http"
|
||||||
version = "3.10.0"
|
version = "3.10.0"
|
||||||
@@ -710,6 +725,7 @@ dependencies = [
|
|||||||
"futures-task",
|
"futures-task",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"pin-utils",
|
"pin-utils",
|
||||||
|
"slab",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1090,6 +1106,7 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
|||||||
name = "lootakalenteri-backend"
|
name = "lootakalenteri-backend"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"actix-cors",
|
||||||
"actix-rt",
|
"actix-rt",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|||||||
@@ -8,4 +8,10 @@ Asenna diesel-cli
|
|||||||
|
|
||||||
Muuta migrations_directory osoittamaan oikeaan paikkaan diesel.tomlissa.
|
Muuta migrations_directory osoittamaan oikeaan paikkaan diesel.tomlissa.
|
||||||
|
|
||||||
|
### Päivitä kanta
|
||||||
|
|
||||||
diesel migration run
|
diesel migration run
|
||||||
|
|
||||||
|
### Luo uusi migraatio
|
||||||
|
|
||||||
|
diesel migration generate <nimi>
|
||||||
19
migrations/2025-06-27-152623_orders_2025_1/down.sql
Normal file
19
migrations/2025-06-27-152623_orders_2025_1/down.sql
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
DELETE FROM loota_customer;
|
||||||
|
DELETE FROM loota_order;
|
||||||
|
DELETE FROM loota_box;
|
||||||
|
|
||||||
|
insert into loota_customer (identifier) values ( 'customer1');
|
||||||
|
insert into loota_customer (identifier) values ( 'customer2');
|
||||||
|
|
||||||
|
insert into loota_order (customer_id, location) values ( (select id from loota_customer where identifier = 'customer1'), 'location1');
|
||||||
|
insert into loota_order (customer_id, location) values ( (select id from loota_customer where identifier = 'customer2'), 'location1');
|
||||||
|
|
||||||
|
insert into loota_box (order_id, delivery_date) values ( (select id from loota_order where customer_id = (select id from loota_customer where identifier = 'customer1')), '2025-04-15 10:00:00+00');
|
||||||
|
insert into loota_box (order_id, delivery_date) values ( (select id from loota_order where customer_id = (select id from loota_customer where identifier = 'customer1')), '2025-04-16 10:00:00+00');
|
||||||
|
insert into loota_box (order_id, delivery_date) values ( (select id from loota_order where customer_id = (select id from loota_customer where identifier = 'customer1')), '2025-04-17 10:00:00+00');
|
||||||
|
insert into loota_box (order_id, delivery_date) values ( (select id from loota_order where customer_id = (select id from loota_customer where identifier = 'customer1')), '2025-04-18 10:00:00+00');
|
||||||
|
|
||||||
|
insert into loota_box (order_id, delivery_date) values ( (select id from loota_order where customer_id = (select id from loota_customer where identifier = 'customer2')), '2025-04-15 10:00:00+00');
|
||||||
|
insert into loota_box (order_id, delivery_date) values ( (select id from loota_order where customer_id = (select id from loota_customer where identifier = 'customer2')), '2025-05-16 10:00:00+00');
|
||||||
|
insert into loota_box (order_id, delivery_date) values ( (select id from loota_order where customer_id = (select id from loota_customer where identifier = 'customer2')), '2025-06-17 10:00:00+00');
|
||||||
|
insert into loota_box (order_id, delivery_date) values ( (select id from loota_order where customer_id = (select id from loota_customer where identifier = 'customer2')), '2025-07-18 10:00:00+00');
|
||||||
1172
migrations/2025-06-27-152623_orders_2025_1/up.sql
Normal file
1172
migrations/2025-06-27-152623_orders_2025_1/up.sql
Normal file
File diff suppressed because it is too large
Load Diff
1169
scripts/boxes.sql
Normal file
1169
scripts/boxes.sql
Normal file
File diff suppressed because it is too large
Load Diff
112
scripts/data-gen-from-csv.py
Normal file
112
scripts/data-gen-from-csv.py
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
import csv
|
||||||
|
import os
|
||||||
|
|
||||||
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
csv_livo_path = os.path.join(script_dir, 'livo-boxes.csv')
|
||||||
|
csv_pienet_path = os.path.join(script_dir, 'pienet-boxes.csv')
|
||||||
|
csv_isot_path = os.path.join(script_dir, 'isot-boxes.csv')
|
||||||
|
sql_path = os.path.join(script_dir, 'boxes.sql')
|
||||||
|
|
||||||
|
insert_lines = []
|
||||||
|
|
||||||
|
with open(csv_livo_path, encoding='utf-8') as csvfile:
|
||||||
|
insert_lines.append("")
|
||||||
|
insert_lines.append("-- Livonsaari")
|
||||||
|
|
||||||
|
reader = csv.DictReader(csvfile)
|
||||||
|
rows = list(reader)
|
||||||
|
|
||||||
|
if not rows:
|
||||||
|
print("No data in CSV.")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
for row in rows:
|
||||||
|
identifier = row['identifier']
|
||||||
|
location = row['location']
|
||||||
|
if identifier == '' or location == '':
|
||||||
|
print(f"Skipping row with empty identifier or location: {row}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
insert_lines.append(f"INSERT INTO loota_customer (identifier) VALUES ('{identifier}');")
|
||||||
|
insert_lines.append(f"INSERT INTO loota_order(customer_id, location) VALUES ((SELECT id FROM loota_customer WHERE identifier = '{identifier}'), '{location}');")
|
||||||
|
|
||||||
|
# Add boxes
|
||||||
|
for date in set(row).difference({'identifier', 'location', ''}):
|
||||||
|
if row[date] == '':
|
||||||
|
continue
|
||||||
|
|
||||||
|
day = int(date.split('.')[0])
|
||||||
|
month = int(date.split('.')[1])
|
||||||
|
date_str = f"2025-{month:02}-{day:02} 10:00:00+00"
|
||||||
|
|
||||||
|
insert_lines.append(f"INSERT INTO loota_box (order_id, delivery_date) VALUES ((SELECT id FROM loota_order WHERE customer_id = (SELECT id FROM loota_customer WHERE identifier = '{identifier}')), '{date_str}');")
|
||||||
|
|
||||||
|
with open(csv_pienet_path, encoding='utf-8') as csvfile:
|
||||||
|
insert_lines.append("")
|
||||||
|
insert_lines.append("-- Pienet")
|
||||||
|
|
||||||
|
reader = csv.DictReader(csvfile)
|
||||||
|
rows = list(reader)
|
||||||
|
|
||||||
|
if not rows:
|
||||||
|
print("No data in CSV.")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
for row in rows:
|
||||||
|
identifier = row['identifier']
|
||||||
|
location = row['location']
|
||||||
|
if identifier == '' or location == '':
|
||||||
|
print(f"Skipping row with empty identifier or location: {row}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
insert_lines.append(f"INSERT INTO loota_customer (identifier) VALUES ('{identifier}');")
|
||||||
|
insert_lines.append(f"INSERT INTO loota_order(customer_id, location) VALUES ((SELECT id FROM loota_customer WHERE identifier = '{identifier}'), '{location}');")
|
||||||
|
|
||||||
|
# Add boxes
|
||||||
|
for date in set(row).difference({'identifier', 'location', ''}):
|
||||||
|
if row[date] == '':
|
||||||
|
continue
|
||||||
|
|
||||||
|
day = int(date.split('.')[0])
|
||||||
|
month = int(date.split('.')[1])
|
||||||
|
date_str = f"2025-{month:02}-{day:02} 10:00:00+00"
|
||||||
|
|
||||||
|
insert_lines.append(f"INSERT INTO loota_box (order_id, delivery_date) VALUES ((SELECT id FROM loota_order WHERE customer_id = (SELECT id FROM loota_customer WHERE identifier = '{identifier}')), '{date_str}');")
|
||||||
|
|
||||||
|
with open(csv_isot_path, encoding='utf-8') as csvfile:
|
||||||
|
insert_lines.append("")
|
||||||
|
insert_lines.append("-- Isot")
|
||||||
|
|
||||||
|
reader = csv.DictReader(csvfile)
|
||||||
|
rows = list(reader)
|
||||||
|
|
||||||
|
if not rows:
|
||||||
|
print("No data in CSV.")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
for row in rows:
|
||||||
|
identifier = row['identifier']
|
||||||
|
location = row['location']
|
||||||
|
if identifier == '' or location == '':
|
||||||
|
print(f"Skipping row with empty identifier or location: {row}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
insert_lines.append(f"INSERT INTO loota_customer (identifier) VALUES ('{identifier}');")
|
||||||
|
insert_lines.append(f"INSERT INTO loota_order(customer_id, location) VALUES ((SELECT id FROM loota_customer WHERE identifier = '{identifier}'), '{location}');")
|
||||||
|
|
||||||
|
# Add boxes
|
||||||
|
for date in set(row).difference({'identifier', 'location', ''}):
|
||||||
|
if row[date] == '':
|
||||||
|
continue
|
||||||
|
|
||||||
|
day = int(date.split('.')[0])
|
||||||
|
month = int(date.split('.')[1])
|
||||||
|
date_str = f"2025-{month:02}-{day:02} 10:00:00+00"
|
||||||
|
|
||||||
|
insert_lines.append(f"INSERT INTO loota_box (order_id, delivery_date) VALUES ((SELECT id FROM loota_order WHERE customer_id = (SELECT id FROM loota_customer WHERE identifier = '{identifier}')), '{date_str}');")
|
||||||
|
|
||||||
|
os.makedirs(os.path.dirname(sql_path), exist_ok=True)
|
||||||
|
with open(sql_path, 'w', encoding='utf-8') as f:
|
||||||
|
f.write('\n'.join(insert_lines))
|
||||||
|
|
||||||
|
print(f"Generated SQL with {len(insert_lines)} rows to {sql_path}")
|
||||||
46
scripts/isot-boxes.csv
Normal file
46
scripts/isot-boxes.csv
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
location,identifier,25.6.,2.7.,9.7.,16.7.,23.7.,30.7.,6.8.,13.8.,20.8.,27.8.,3.9.,10.9.,17.9.,24.9.,1.10.,8.10.,15.10.,
|
||||||
|
Askainen,pinaattihierakka,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Askainen,purjo,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Askainen,paparperi,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kirjakahvila,ruoholaukka,,,1,,1,,1,,1,,1,,1,,1,,,
|
||||||
|
Kirjakahvila,ruohosipuli,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kirjakahvila,ruokaparsa,,,,1,,1,,1,,1,,1,,1,,,,
|
||||||
|
Kirjakahvila,ruokasalaatti,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kirjakahvila,jäävuorisalaatti,,,1,,1,,1,,1,,1,,1,,1,,,
|
||||||
|
Kirjakahvila,sareptansinappi,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kirjakahvila,lehtiselleri,,,1,,1,,1,,1,,1,,1,,1,,,
|
||||||
|
Kirjakahvila,rosmariini,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kirjakahvila,sikuri,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kissakahvila,sinappikaali,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kissakahvila,tarhamaltsa,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kissakahvila,valkosipuli,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kissakahvila,vesikrassi,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kissakahvila,vihanneskrassi,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
kissakahvila,vihannesportulakka,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kissakahvila,vuononkaali,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kissakahvila,herne,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Kissakahvila,härkäpapu,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Koroinen,jättikurpitsa,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Koroinen,kukkalaali,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Koroinen,parsakaali,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Koroinen,kurkku,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Koroinen,kesäkurpitsa,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Koroinen,spagettikurpitsa,,,,1,,1,,1,,1,,1,,1,,,,
|
||||||
|
Koroinen,latva-artisokka,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Koroinen,maissi,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Koroinen,munakoiso,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Koroinen,okra,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Masku,paprika,,,1,,1,,1,,1,,1,,1,,1,,,
|
||||||
|
Masku,parsaherne,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Merimasku,tarhapapu,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Naantali,tomaatti,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Naantali,kirsikkatomaatti,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Naantali,basilika,,,,1,,1,,1,,1,,1,,1,,,,
|
||||||
|
Naantali,korianteri,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Raisio,kynteli,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Raisio,piparminttu,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Raisio,viherminttu,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Raisio,laventeli,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Raisio,lipstikka,,,,,,,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
Viherlassila,mukulaselleri,,,,1,,1,,1,,1,,1,,1,,,,
|
||||||
|
Viherlassila,nokkonen,,,1,1,1,1,1,1,1,1,1,1,1,1,1,,,
|
||||||
|
9
scripts/livo-boxes.csv
Normal file
9
scripts/livo-boxes.csv
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
location,identifier,28.6.,5.7.,12.7.,19.7.,26.7.,2.8.,9.8.,16.8.,23.8.,30.8.,6.9.,13.9.,20.9.,27.9.,4.10.,11.10.,18.10.,
|
||||||
|
Livonsaari,bataatti,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
Livonsaari,intianlootus,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
Livonsaari,isotakiainen,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
Livonsaari,kaurajuuri,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
Livonsaari,lanttu,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
|
Livonsaari,maakastanja,,,1,,1,,1,,1,,1,,1,,1,,,
|
||||||
|
Livonsaari,maniokki,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Livonsaari,mukulakäenkaali,,,,1,,1,,1,,1,,1,,1,,1,,
|
||||||
|
34
scripts/pienet-boxes.csv
Normal file
34
scripts/pienet-boxes.csv
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
location,identifier,25.6.,2.7.,9.7.,16.7.,23.7.,30.7.,6.8.,13.8.,20.8.,27.8.,3.9.,10.9.,17.9.,24.9.,1.10.,8.10.,15.10,
|
||||||
|
Askainen,mustajuuri,,,1,,1,,1,,1,,1,,1,,1,,,
|
||||||
|
Askainen,nauris,,,,1,,1,,1,,1,,1,,1,,1,,
|
||||||
|
Kirjakahvila,nuolijuuri,,,,,,,1,1,1,1,1,1,1,1,1,1,,
|
||||||
|
Kirjakahvila,palsternakka,,,,,,,1,1,1,1,1,1,1,1,1,1,,
|
||||||
|
Kirjakahvila,persilja,,,,,,,1,1,1,1,1,1,1,1,1,1,,
|
||||||
|
Kirjakahvila,peruna,,,1,,1,,1,,1,,1,,1,,1,,,
|
||||||
|
Kirjakahvila,piparjuuri,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Kirjakahvila,porkkana,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Kissakahvila,punajuuri,,,,,,,1,1,1,1,1,1,1,1,1,1,,
|
||||||
|
Kissakahvila,retiisi,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Kissakahvila,selleri,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Kissakahvila,ruotiselleri,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Kissakahvila,taaro,,,,1,,1,,1,,1,,1,,1,,1,,
|
||||||
|
Koroinen,ulluko,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Koroinen,vesikastanja,,,,,,,1,1,1,1,1,1,1,1,1,1,,
|
||||||
|
Koroinen,endiivi,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Koroinen,merikaali,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Koroinen,fenkoli,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Koroinen,keräkaali,,,1,,1,,1,,1,,1,,1,,1,,,
|
||||||
|
Koroinen,kiinankaali,,,,,,,1,1,1,1,1,1,1,1,1,1,,
|
||||||
|
Merimasku,kurttukaali,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Merimasku,kyssäkaali,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Naantali,lehtikaali,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Naantali,punakaali,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Naantali,ruusukaali,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Naantali,kardoni,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Naantali,keltasipuli,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Raisio,salottisipuli,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Raisio,lamopinaatti,,,,1,,1,,1,,1,,1,,1,,1,,
|
||||||
|
Viherlassila,lehtimangoldi,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Viherlassila,pillisipuli,,,1,,1,,1,,1,,1,,1,,1,,,
|
||||||
|
Viherlassila,talvisipuli,,,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||||
|
Viherlassila,pinaatti,,,,1,,1,,1,,1,,1,,1,,1,,
|
||||||
|
Reference in New Issue
Block a user