improved text output to include totals
@@ -333,7 +333,9 @@ def counts(
count_method = T.counts_recent
if csv:
- click.echo(f'start,end,count')
+ click.echo(f'start,end,{granularity}_count')
+
+ total_tweets = 0
for result in count_method(
query,
@@ -345,7 +347,8 @@ def counts(
):
if text:
for r in result['data']:
- click.echo(f'{r["start"]} - {r["end"]}: {r["tweet_count"]}')
+ total_tweets += r['tweet_count']
+ click.echo('{start} - {end}: {tweet_count:,}'.format(**r))
elif csv:
for r in result['data']:
click.echo(f'{r["start"]},{r["end"]},{r["tweet_count"]}')
@@ -355,6 +358,14 @@ def counts(
if limit != 0 and count >= limit:
break
+ if text:
+ click.echo(
+ click.style(
+ '\nTotal Tweets: {:,}\n'.format(total_tweets),
+ fg='green'
+ )
+ )
+
@twarc2.command("tweet")
@click.option("--pretty", is_flag=True, default=False, help="Pretty print the JSON")
