Skip to content

Commit

Permalink
Deploy version 1.16 + all locations update (#356)
Browse files Browse the repository at this point in the history
* 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
jannisborn and NinaWie authored Oct 21, 2024
1 parent 31702a7 commit 829c31a
Show file tree
Hide file tree
Showing 5 changed files with 69,212 additions and 57,979 deletions.
8 changes: 0 additions & 8 deletions PennyMe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
8319D8D027414AC100E97D93 /* ZoomViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8319D8CF27414AC100E97D93 /* ZoomViewController.swift */; };
837476502CADDAD800812146 /* StatisticsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8374764F2CADDAD800812146 /* StatisticsViewController.swift */; };
837476532CB0918000812146 /* DGCharts in Frameworks */ = {isa = PBXBuildFile; productRef = 837476522CB0918000812146 /* DGCharts */; };
837476552CB0918000812146 /* DGChartsDynamic in Frameworks */ = {isa = PBXBuildFile; productRef = 837476542CB0918000812146 /* DGChartsDynamic */; };
839CF440267B78AB00E259D9 /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 839CF43F267B78AB00E259D9 /* SettingsViewController.swift */; };
83BAF44E2A792D45002365D2 /* ImagePickerHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83BAF44D2A792D45002365D2 /* ImagePickerHelper.swift */; };
83D226CD2620F4910050ED9E /* PinViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83D226CC2620F4910050ED9E /* PinViewController.swift */; };
Expand Down Expand Up @@ -84,7 +83,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
837476552CB0918000812146 /* DGChartsDynamic in Frameworks */,
837476532CB0918000812146 /* DGCharts in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -197,7 +195,6 @@
name = PennyMe;
packageProductDependencies = (
837476522CB0918000812146 /* DGCharts */,
837476542CB0918000812146 /* DGChartsDynamic */,
);
productName = PennyMe;
productReference = 9F9F31A12300B40900C0E854 /* PennyMe.app */;
Expand Down Expand Up @@ -688,11 +685,6 @@
package = 837476512CB0918000812146 /* XCRemoteSwiftPackageReference "Charts" */;
productName = DGCharts;
};
837476542CB0918000812146 /* DGChartsDynamic */ = {
isa = XCSwiftPackageProductDependency;
package = 837476512CB0918000812146 /* XCRemoteSwiftPackageReference "Charts" */;
productName = DGChartsDynamic;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 9F9F31992300B40900C0E854 /* Project object */;
Expand Down
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
}
67 changes: 67 additions & 0 deletions backend/scripts/merge_jsons.py
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()
Loading

0 comments on commit 829c31a

Please sign in to comment.