Skip to content

Commit

Permalink
Merge pull request #57 from kshitijrajsharma/feature/key_value
Browse files Browse the repository at this point in the history
Feature : Key Value Combination stats
  • Loading branch information
kshitijrajsharma authored Oct 30, 2023
2 parents d480e2b + e31e8b9 commit ea9f549
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## v0.2.0 (2023-10-30)

### Feat

- intorduces key value stats feature for all the stats type
- Turkey Data and Frontend Integration

## v0.1.33 (2023-07-10)

## v0.1.32 (2023-07-10)

### Perf
Expand Down
24 changes: 24 additions & 0 deletions osmsg/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,19 @@ def collect_changefile_stats(
if tags:
for key, value in tags:
if action != "delete": # we don't need deleted tags
if key_value:
users[user][f"tags_{action}"].setdefault(f"{key}={value}", 0)
users[user][f"tags_{action}"][f"{key}={value}"] += 1
users[user][f"tags_{action}"].setdefault(key, 0)
users[user][f"tags_{action}"][key] += 1
if summary:
if key_value:
summary_interval[timestamp][f"tags_{action}"].setdefault(
f"{key}={value}", 0
)
summary_interval[timestamp][f"tags_{action}"][
f"{key}={value}"
] += 1
summary_interval[timestamp][f"tags_{action}"].setdefault(key, 0)
summary_interval[timestamp][f"tags_{action}"][key] += 1

Expand Down Expand Up @@ -647,6 +657,14 @@ def parse_args():
help="Extract statistics of all of the unique tags and its count",
default=False,
)

parser.add_argument(
"--key_value",
action="store_true",
help="Extracts stats for Unique combination of tags key and value by default it will count for unique key on --all_tags",
default=False,
)

parser.add_argument(
"--temp",
action="store_true",
Expand Down Expand Up @@ -694,6 +712,10 @@ def main():
if not os.path.exists(base_path):
os.makedirs(base_path)

if args.key_value:
args.all_tags = True
print("Enabling all_tags option as key_value is passed")

if args.update:
if args.read_from_metadata:
print("Error : Option not allowed : read_from_metadata along with --update")
Expand Down Expand Up @@ -784,6 +806,7 @@ def main():
global additional_tags
global cookies
global all_tags
global key_value
global hashtags
global length
global changeset_meta
Expand All @@ -795,6 +818,7 @@ def main():
global remove_temp_files

all_tags = args.all_tags
key_value = args.key_value
additional_tags = args.tags
hashtags = args.hashtags
cookies = None
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "osmsg"
version = "0.1.33"
version = "0.2.0"
description = "OpenStreetMap Stats Generator : Commandline"
readme = "README.md"
authors = [{name = "Kshitij Raj Sharma", email = "[email protected]"}]
Expand Down

0 comments on commit ea9f549

Please sign in to comment.