Skip to content

Commit

Permalink
feat: intorduces key value stats feature for all the stats type
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Oct 30, 2023
1 parent d480e2b commit c5ba2ce
Showing 1 changed file with 24 additions and 0 deletions.
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

0 comments on commit c5ba2ce

Please sign in to comment.