Skip to content

Commit

Permalink
update data
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorcz committed Feb 1, 2025
1 parent cc230d6 commit fd2a294
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
17 changes: 15 additions & 2 deletions generate_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,29 @@ def process_json_file(filepath):

# Obtém a data do lançamento
launch_datetime = first_entry.get("datetime", "Desconhecido")
# Converte a data para o formato dia/mês/ano
formatted_datetime = format_date(launch_datetime)

return {
"launch_city": city,
"max_altitude": max_altitude,
"launch_datetime": launch_datetime
"launch_datetime": formatted_datetime
}
except Exception as e:
print(f"Erro ao processar {filepath}: {e}")
return None

def format_date(date_str):
"""Converte a data para o formato dia/mês/ano."""
try:
# Converte a data ISO para datetime
date_obj = datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S.%fZ")
# Retorna a data no formato dia/mês/ano
return date_obj.strftime("%d/%m/%Y")
except Exception as e:
print(f"Erro ao formatar a data: {e}")
return "Desconhecido"

def load_existing_index():
"""Carrega o index.json existente para evitar reprocessamento."""
if os.path.exists(INDEX_FILE):
Expand Down Expand Up @@ -94,7 +107,7 @@ def generate_index():
# Só atualiza o index.json se houver novos arquivos
if new_entries:
# Ordena as novas entradas por data de lançamento (mais recente primeiro)
new_entries.sort(key=lambda x: datetime.strptime(x["launch_datetime"], "%Y-%m-%dT%H:%M:%S.%fZ"), reverse=True)
new_entries.sort(key=lambda x: datetime.strptime(x["launch_datetime"], "%d/%m/%Y"), reverse=True)

# Atualiza o índice com as novas entradas ordenadas
updated_index = existing_index + new_entries
Expand Down
42 changes: 21 additions & 21 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,104 +4,104 @@
"download_url": "https://zenitheesc.github.io/launches-data/contents/014_J4840095_day_2.json",
"launch_city": "Brasília",
"max_altitude": 26933.76074,
"launch_datetime": "2022-12-04T17:09:53.000000Z"
"launch_datetime": "04/12/2022"
},
{
"name": "011_J4830342_day_0.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/011_J4830342_day_0.json",
"launch_city": "São Carlos",
"max_altitude": 25239.60051,
"launch_datetime": "2022-10-09T12:57:22.000000Z"
"launch_datetime": "09/10/2022"
},
{
"name": "012_J4840095_day_0.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/012_J4840095_day_0.json",
"launch_city": "São Carlos",
"max_altitude": 23232.01193,
"launch_datetime": "2022-10-09T12:46:19.000000Z"
"launch_datetime": "09/10/2022"
},
{
"name": "013_J4840152_day_0.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/013_J4840152_day_0.json",
"launch_city": "São Carlos",
"max_altitude": 6760.75058,
"launch_datetime": "2022-10-09T12:42:14.000000Z"
"launch_datetime": "09/10/2022"
},
{
"name": "010_J4830341_day_0.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/010_J4830341_day_0.json",
"launch_city": "São Carlos",
"max_altitude": 22717.87148,
"launch_datetime": "2022-10-09T12:39:26.999000Z"
},
{
"name": "009_T0351008_day_4.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/009_T0351008_day_4.json",
"launch_city": "Parnamirim",
"max_altitude": 25934.54936,
"launch_datetime": "2022-09-02T17:32:19.000000Z"
"launch_datetime": "09/10/2022"
},
{
"name": "008_T0350530_day_3.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/008_T0350530_day_3.json",
"launch_city": "Parnamirim",
"max_altitude": 27381.78636,
"launch_datetime": "2022-09-02T13:07:11.995000Z"
"launch_datetime": "02/09/2022"
},
{
"name": "009_T0351008_day_4.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/009_T0351008_day_4.json",
"launch_city": "Parnamirim",
"max_altitude": 25934.54936,
"launch_datetime": "02/09/2022"
},
{
"name": "007_T4220752_day_2.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/007_T4220752_day_2.json",
"launch_city": "Rio de Janeiro",
"max_altitude": 24508.22591,
"launch_datetime": "2022-08-20T17:48:17.988000Z"
"launch_datetime": "20/08/2022"
},
{
"name": "006_T4220752_day_1.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/006_T4220752_day_1.json",
"launch_city": "Santa Maria",
"max_altitude": 25022.38281,
"launch_datetime": "2022-08-13T05:23:35.995000Z"
"launch_datetime": "13/08/2022"
},
{
"name": "005_T4150774_day_1.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/005_T4150774_day_1.json",
"launch_city": "Tatuí",
"max_altitude": 22875.68551,
"launch_datetime": "2022-08-06T02:28:49.000Z"
"launch_datetime": "06/08/2022"
},
{
"name": "004_T0351008_day_1.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/004_T0351008_day_1.json",
"launch_city": "São Gonçalo",
"max_altitude": 24397.9039,
"launch_datetime": "2022-07-16T00:00:00.000000Z"
"launch_datetime": "16/07/2022"
},
{
"name": "003_T0351008_day_0.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/003_T0351008_day_0.json",
"launch_city": "Rio de Janeiro",
"max_altitude": 12155.96184,
"launch_datetime": "2022-07-15T23:31:55.000000Z"
"launch_datetime": "15/07/2022"
},
{
"name": "002_T0350530_day_0.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/002_T0350530_day_0.json",
"launch_city": "Rio de Janeiro",
"max_altitude": 24684.63735,
"launch_datetime": "2022-04-20T11:33:47.000000Z"
"launch_datetime": "20/04/2022"
},
{
"name": "001_T4150774_day_0.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/001_T4150774_day_0.json",
"launch_city": "Londrina",
"max_altitude": 26228.84185,
"launch_datetime": "2022-02-28T11:33:40.000000Z"
"launch_datetime": "28/02/2022"
},
{
"name": "000_T4220752_day_0.json",
"download_url": "https://zenitheesc.github.io/launches-data/contents/000_T4220752_day_0.json",
"launch_city": "Londrina",
"max_altitude": 25927.02095,
"launch_datetime": "2022-02-07T11:34:43.000000Z"
"launch_datetime": "07/02/2022"
}
]

0 comments on commit fd2a294

Please sign in to comment.