@@ -112,18 +112,19 @@ def _aggregate_by_search_term(
112112 return aggregated
113113
114114
115- def _display_share_table (data : list [SearchTermShareData ]) -> None :
115+ def _display_share_table (data : list [SearchTermShareData ], limit : int = 100 ) -> None :
116116 """Display impression share data in a rich table."""
117117 table = Table (title = "Impression Share Analysis" , show_lines = False )
118118
119- table .add_column ("Search Term" , style = "cyan" , no_wrap = False , max_width = 40 )
119+ table .add_column ("App" , style = "magenta" , no_wrap = True , max_width = 25 )
120+ table .add_column ("Search Term" , style = "cyan" , no_wrap = False , max_width = 35 )
120121 table .add_column ("Country" , style = "dim" , width = 4 )
121122 table .add_column ("Share" , justify = "right" , style = "green" , width = 10 )
122123 table .add_column ("Rank" , justify = "center" , width = 4 )
123124 table .add_column ("Pop" , justify = "center" , width = 3 )
124125 table .add_column ("Date" , style = "dim" , width = 10 )
125126
126- for row in data [:50 ]: # Limit to 50 rows
127+ for row in data [:limit ]:
127128 # Color share based on value
128129 share_style = "green"
129130 if row .high_share :
@@ -133,7 +134,8 @@ def _display_share_table(data: list[SearchTermShareData]) -> None:
133134 share_style = "yellow"
134135
135136 table .add_row (
136- row .search_term [:40 ],
137+ row .app_name [:25 ] if row .app_name else "" ,
138+ row .search_term [:35 ],
137139 row .country ,
138140 f"[{ share_style } ]{ row .share_range } [/{ share_style } ]" ,
139141 row .rank_display ,
@@ -143,8 +145,8 @@ def _display_share_table(data: list[SearchTermShareData]) -> None:
143145
144146 console .print (table )
145147
146- if len (data ) > 50 :
147- print_info (f"Showing 50 of { len (data )} results. Use --output to export all." )
148+ if len (data ) > limit :
149+ print_info (f"Showing { limit } of { len (data )} results. Use --limit or -- output to see all." )
148150
149151
150152@app .command ("analyze" )
@@ -168,6 +170,14 @@ def analyze_impression_share(
168170 str | None ,
169171 typer .Option ("--search" , "-s" , help = "Filter by search term (partial match)" ),
170172 ] = None ,
173+ app : Annotated [
174+ str | None ,
175+ typer .Option ("--app" , "-a" , help = "Filter by app name (partial match)" ),
176+ ] = None ,
177+ limit : Annotated [
178+ int ,
179+ typer .Option ("--limit" , "-l" , help = "Max rows to display (0 for all)" ),
180+ ] = 100 ,
171181 output : Annotated [
172182 str | None ,
173183 typer .Option ("--output" , "-o" , help = "Export to CSV file" ),
@@ -182,6 +192,7 @@ def analyze_impression_share(
182192 asa impression-share analyze --days 14
183193 asa impression-share analyze --country US --min-share 30
184194 asa impression-share analyze --search "calculator" --output report.csv
195+ asa impression-share analyze --app "Chippy" --limit 200
185196 """
186197 client = get_client ()
187198
@@ -219,10 +230,15 @@ def analyze_impression_share(
219230 # Parse data
220231 data = _parse_report_data (report )
221232
222- # Aggregate by search term (keep latest)
233+ # Aggregate by search term + app (keep latest)
223234 aggregated = _aggregate_by_search_term (data )
224235 data = list (aggregated .values ())
225236
237+ # Apply app filter
238+ if app :
239+ app_lower = app .lower ()
240+ data = [d for d in data if d .app_name and app_lower in d .app_name .lower ()]
241+
226242 # Apply search filter
227243 if search :
228244 search_lower = search .lower ()
@@ -276,7 +292,9 @@ def analyze_impression_share(
276292 except Exception as e :
277293 print_error ("Export failed" , str (e ))
278294
279- _display_share_table (data )
295+ # Use limit=0 to show all, otherwise use specified limit
296+ display_limit = len (data ) if limit == 0 else limit
297+ _display_share_table (data , limit = display_limit )
280298
281299 # Summary
282300 low_share_count = sum (1 for d in data if d .high_share and d .high_share < 0.3 )
0 commit comments