crismunoz commited on
Commit
d8e8466
·
1 Parent(s): 07048d9
Files changed (1) hide show
  1. app.py +21 -24
app.py CHANGED
@@ -143,7 +143,7 @@ def program():
143
  item = [item for item in filtered_data_by_group if item['risk'] == risk][0]
144
 
145
  st.header(risk)
146
- st.write(f"**Description**: {item['description']}")
147
 
148
  # Define the number of columns
149
  num_columns = 3
@@ -181,11 +181,9 @@ def program():
181
  # Display the filtered news as a grid of cards
182
  if len(filtered_data_by_group) > 0:
183
  for risk in set([item['risk'] for item in filtered_data_by_group]):
 
184
  st.header(risk)
185
- # Filter data based on current risk
186
- filtered_data_by_risk = [item for item in filtered_data_by_group if item['risk'] == risk]
187
-
188
- # Define the number of columns
189
  num_columns = 3
190
  col_index = 0
191
 
@@ -195,26 +193,25 @@ def program():
195
  # Initialize an empty row
196
  row = grid.columns(num_columns)
197
 
198
- for item in filtered_data_by_risk:
199
- for news in item['mitigators']:
200
- with row[col_index]:
201
- st.markdown(
202
- f"""
203
- <div class="grid-item">
204
- <div class="card">
205
- <h3>{news['title']}</h3>
206
- <p>{news['recommendation']}</p>
207
- <p><b>Year:</b> {news['year']}</p>
208
- <a href="{news['link']}" target="_blank">Read more</a>
209
- </div>
210
  </div>
211
- """,
212
- unsafe_allow_html=True
213
- )
214
- col_index = (col_index + 1) % num_columns
215
- # Start a new row after the last column
216
- if col_index == 0:
217
- row = grid.columns(num_columns)
 
218
 
219
  if len(filtered_data_by_group) == 0:
220
  st.write("No news found for the selected task and group.")
 
143
  item = [item for item in filtered_data_by_group if item['risk'] == risk][0]
144
 
145
  st.header(risk)
146
+ st.write(item['description'])
147
 
148
  # Define the number of columns
149
  num_columns = 3
 
181
  # Display the filtered news as a grid of cards
182
  if len(filtered_data_by_group) > 0:
183
  for risk in set([item['risk'] for item in filtered_data_by_group]):
184
+ item = [item for item in filtered_data_by_group if item['risk'] == risk][0]
185
  st.header(risk)
186
+ st.write(item['description'])
 
 
 
187
  num_columns = 3
188
  col_index = 0
189
 
 
193
  # Initialize an empty row
194
  row = grid.columns(num_columns)
195
 
196
+ for news in item['mitigators']:
197
+ with row[col_index]:
198
+ st.markdown(
199
+ f"""
200
+ <div class="grid-item">
201
+ <div class="card">
202
+ <h3>{news['title']}</h3>
203
+ <p>{news['recommendation']}</p>
204
+ <p><b>Year:</b> {news['year']}</p>
205
+ <a href="{news['link']}" target="_blank">Read more</a>
 
 
206
  </div>
207
+ </div>
208
+ """,
209
+ unsafe_allow_html=True
210
+ )
211
+ col_index = (col_index + 1) % num_columns
212
+ # Start a new row after the last column
213
+ if col_index == 0:
214
+ row = grid.columns(num_columns)
215
 
216
  if len(filtered_data_by_group) == 0:
217
  st.write("No news found for the selected task and group.")