Skip to content

Commit

Permalink
feat: Make service work with json (DEV-3930) (#146)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcin Procyk <marcin.procyk@dasch.swiss>
  • Loading branch information
seakayone and mpro7 authored Jul 29, 2024
1 parent c453d59 commit 184c710
Show file tree
Hide file tree
Showing 103 changed files with 25,099 additions and 24,949 deletions.
163 changes: 159 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ log = "0.4.20" # logging facade
once_cell = "1.19.0"
pid1 = "0.1.1"
serde = { version = "1", features = ["derive"] }
serde_with = "3.9.0"
serde_json = "1" # JSON serialization
serde_yaml = "0.9"
nonempty = { version = "0.10.0", features = ["serialize"] }
valico = "4.0.0"
tokio = { version = "1", features = ["rt", "macros", "rt-multi-thread"] }
tokio-test = "0.4.2"
tower = "0.4.13"
tower-http = { version = "0.5.0", features = ["trace", "fs"] }
tower-http = { version = "0.5.0", features = ["trace", "fs", "cors"] }
hyper = "1.0.1"
regex = "1.5.4"
thiserror = "1.0.56"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = [
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM rust:1-slim-bookworm as builder-rs
FROM rust:1-slim-bookworm AS builder-rs
WORKDIR /dsp-meta
COPY . .
RUN cargo install --path ./dsp-meta-cmd

FROM node:21-bookworm-slim as builder-node
FROM node:21-bookworm-slim AS builder-node
WORKDIR /dsp-meta
COPY . .
RUN cd web-frontend && yarn install && yarn run build
Expand Down
79 changes: 79 additions & 0 deletions data/add_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import os
import json

# List of ongoing shortcodes
ongoing_shortcodes = [
"0102",
"0103",
"0105",
"0106",
"0107",
"0112",
"0114",
"0116",
"0118",
"0119",
"0121",
"0801",
"0804",
"0805",
"0806",
"0807",
"080C",
"080E",
"0810",
"0812",
"0813",
"0816",
"081B",
"0820",
"0827",
"082B",
"082C",
"0836",
"0838",
"083A",
"083B",
"083C",
"083E",
"0843",
"0844",
"0849",
"084A",
"084E"
]

def update_json_files(folder_path):
print(ongoing_shortcodes)
# Iterate through all files in the given folder
for filename in os.listdir(folder_path):
# Check if the file is a JSON file
if filename.endswith(".json"):
file_path = os.path.join(folder_path, filename)

# Read the JSON file
with open(file_path, 'r', encoding='utf-8') as file:
data = json.load(file)

# Check if the "project" and "shortcode" keys exist
if "project" in data and "shortcode" in data["project"]:
shortcode = data["project"]["shortcode"]

# Determine the status based on the shortcode
print (shortcode)
print (shortcode in ongoing_shortcodes)
if shortcode in ongoing_shortcodes:
status = "ongoing"
else:
status = "finished"

# Add or update the "status" property
data["project"]["status"] = status

# Write the updated JSON back to the file
with open(file_path, 'w', encoding='utf-8') as file:
json.dump(data, file, indent=4, ensure_ascii=False)
else:
print(f"File {filename} does not contain the expected structure.")

update_json_files('./json/')
Loading

0 comments on commit 184c710

Please sign in to comment.