Changed dataset dir structure to year/month

This commit is contained in:
spla 2023-06-07 13:28:12 +02:00
pare 9a40889f80
commit 2d19577fb7
S'han modificat 2 arxius amb 14 adicions i 10 eliminacions

Veure arxiu

@ -59,7 +59,7 @@ if __name__ == '__main__':
i = 0 i = 0
while i < 5: while i < len(soft_total_project):
db.write_top_soft(soft_total_project[i], soft_total_users[i], soft_total_mau[i], soft_total_servers[i]) db.write_top_soft(soft_total_project[i], soft_total_users[i], soft_total_mau[i], soft_total_servers[i])

Veure arxiu

@ -13,9 +13,9 @@ def date_string():
month = '{:02d}'.format(now.month) month = '{:02d}'.format(now.month)
year = str(now.year)[2:] year = str(now.year)
return f'{year}{month}{day}' return day, month, year
if __name__ == '__main__': if __name__ == '__main__':
@ -25,15 +25,19 @@ if __name__ == '__main__':
os.makedirs('dataset') os.makedirs('dataset')
date = date_string() day, month, year = date_string()
if not os.path.exists(f'dataset/{date}'): if not os.path.exists(f'dataset/{year}'):
os.makedirs(f'dataset/{date}') os.makedirs(f'dataset/{year}')
filename = f'dataset_{date}.csv' if not os.path.exists(f'dataset/{year}/{month}'):
db.csv_save(f'dataset/{date}/{filename}') os.makedirs(f'dataset/{year}/{month}')
filename = f'dataset_{year}{month}{day}.csv'
db.csv_save(f'dataset/{year}/{month}/{filename}')
fgj = Forgejo() fgj = Forgejo()
@ -41,11 +45,11 @@ if __name__ == '__main__':
try: try:
with open(f'dataset/{date}/{filename}', 'rb') as input_file: with open(f'dataset/{year}/{month}/{filename}', 'rb') as input_file:
data = input_file.read() data = input_file.read()
file = base64.b64encode(data) file = base64.b64encode(data)
response = fgj.repo_owner_create_file(gituser.login, fgj.stats_repo, f'dataset/{date}/{filename}', gituser.email, gituser.login, "main", file, f"{date} fediverse's dataset") response = fgj.repo_owner_create_file(gituser.login, fgj.stats_repo, f'dataset/{year}/{month}/{filename}', gituser.email, gituser.login, "main", file, f"{year}{month}{day} fediverse's dataset")
if 'content' in response: if 'content' in response: