-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy version 1.16 + all locations update (#356)
* feat: location merging script * data: merge/update files * chore * add package resolved file * refactor: chart dependency --------- Co-authored-by: NinaWie <[email protected]>
- Loading branch information
1 parent
31702a7
commit 829c31a
Showing
5 changed files
with
69,212 additions
and
57,979 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
PennyMe.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "charts", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/danielgindi/Charts", | ||
"state" : { | ||
"revision" : "dd9c72e3d7e751e769971092a6bd72d39198ae63", | ||
"version" : "5.1.0" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import json | ||
from copy import deepcopy | ||
from datetime import datetime | ||
from pathlib import Path | ||
|
||
import typer | ||
|
||
app = typer.Typer() | ||
|
||
|
||
@app.command() | ||
def merge_locations(all_file: Path): | ||
with open(all_file, "r") as f: | ||
alll = json.load(f) | ||
server_file = all_file.parent / all_file.name.replace("all", "server") | ||
with open(server_file, "r") as f: | ||
ser = json.load(f) | ||
|
||
ls, la = len(ser["features"]), len(alll["features"]) | ||
print(f"All locations has {la} entries, server locations {ls}") | ||
|
||
youngest_all = sorted( | ||
[ | ||
datetime.strptime(e["properties"]["last_updated"], "%Y-%m-%d") | ||
for e in alll["features"] | ||
] | ||
)[-1] | ||
print(f"Youngest entry in all locations is of {youngest_all}") | ||
|
||
# Merge entries. Start from server locations, otherwise we have to overwrite | ||
new_all = deepcopy(ser) | ||
new_all_ids = [e["properties"]["id"] for e in ser["features"]] | ||
|
||
for allentry in alll["features"][::-1]: | ||
if allentry["properties"]["id"] not in new_all_ids: | ||
new_all["features"].insert(0, allentry) | ||
|
||
print(f"New all locations has {len(new_all['features'])} entries") | ||
|
||
# Delete entries from server locations that are older than youngest in all locations | ||
|
||
new_server = deepcopy(ser) | ||
new_server["features"] = [] | ||
|
||
for e in ser["features"]: | ||
if ( | ||
datetime.strptime(e["properties"]["last_updated"], "%Y-%m-%d") | ||
< youngest_all | ||
): | ||
continue | ||
new_server["features"].append(e) | ||
|
||
print(f"New server location has length {len(new_server['features'])}") | ||
|
||
with open(all_file.parent / all_file.name.replace(".json", "_new.json"), "w") as f: | ||
json.dump(new_all, f, indent=4, ensure_ascii=False) | ||
|
||
with open( | ||
server_file.parent / server_file.name.replace(".json", "_new.json"), "w" | ||
) as f: | ||
json.dump(new_server, f, indent=4, ensure_ascii=False) | ||
|
||
print("Saved data!") | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
Oops, something went wrong.