bradley6597
commited on
Commit
·
e4e0ca7
1
Parent(s):
117ade9
New features!
Browse files
app.py
CHANGED
@@ -111,8 +111,10 @@ def search_index(search_text, sd, ks, sort_by, max_results, user_num, search_tit
|
|
111 |
output_df2 = output_df2.sort_values(by = ['Date Created'], ascending = False)
|
112 |
elif sort_by == 'A-Z':
|
113 |
output_df2 = output_df2.sort_values(by = ['title'], ascending = True)
|
114 |
-
|
115 |
-
|
|
|
|
|
116 |
output_df2 = output_df2[['url']].reset_index(drop = True)
|
117 |
|
118 |
max_cols = 5
|
@@ -134,7 +136,7 @@ def search_index(search_text, sd, ks, sort_by, max_results, user_num, search_tit
|
|
134 |
|
135 |
return('<center>' +
|
136 |
final_df.to_html(escape = False, render_links = True, index = False, header = False) +
|
137 |
-
'</center>')
|
138 |
|
139 |
|
140 |
def search_logging(x: str, request: gr.Request):
|
@@ -194,14 +196,14 @@ with gr.Blocks(css=style) as app:
|
|
194 |
shared_drive = gr.Dropdown(choices = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now'], multiselect = True, label = 'Shared Drive', value = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now'])
|
195 |
key_stage = gr.Dropdown(choices = ['EYFS', 'KS1', 'KS2'], multiselect = True, label = 'Key Stage', value = ['EYFS', 'KS1', 'KS2'])
|
196 |
sort_by = gr.Dropdown(choices = ['Relevance', 'Date Created', 'A-Z'], value = 'Relevance', multiselect = False, label = 'Sort By')
|
197 |
-
max_return = gr.Dropdown(choices = ['10', '25', '50', '75', '100', '250', '500'], value = '
|
198 |
with gr.Row():
|
199 |
search_button = gr.Button(value="Search!")
|
200 |
with gr.Row():
|
201 |
output_df = gr.HTML()
|
202 |
back_top_btn = gr.HTML(back_to_top_btn_html)
|
203 |
-
search_button.click(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search], outputs=output_df)
|
204 |
-
search_prompt.submit(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search], outputs=output_df)
|
205 |
search_button.click(search_logging, inputs=[search_prompt], outputs=None)
|
206 |
search_prompt.submit(search_logging, inputs=[search_prompt], outputs=None)
|
207 |
|
|
|
111 |
output_df2 = output_df2.sort_values(by = ['Date Created'], ascending = False)
|
112 |
elif sort_by == 'A-Z':
|
113 |
output_df2 = output_df2.sort_values(by = ['title'], ascending = True)
|
114 |
+
|
115 |
+
total_returned = 'No. of Results to Return (Total: ' + str(output_df2.shape[0]) + ')'
|
116 |
+
if max_results != 'All':
|
117 |
+
output_df2 = output_df2.head(int(max_results))
|
118 |
output_df2 = output_df2[['url']].reset_index(drop = True)
|
119 |
|
120 |
max_cols = 5
|
|
|
136 |
|
137 |
return('<center>' +
|
138 |
final_df.to_html(escape = False, render_links = True, index = False, header = False) +
|
139 |
+
'</center>', gr.update(label = total_returned))
|
140 |
|
141 |
|
142 |
def search_logging(x: str, request: gr.Request):
|
|
|
196 |
shared_drive = gr.Dropdown(choices = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now'], multiselect = True, label = 'Shared Drive', value = ['Illustrations - 01-10 to 07-22', 'Illustrations - Now'])
|
197 |
key_stage = gr.Dropdown(choices = ['EYFS', 'KS1', 'KS2'], multiselect = True, label = 'Key Stage', value = ['EYFS', 'KS1', 'KS2'])
|
198 |
sort_by = gr.Dropdown(choices = ['Relevance', 'Date Created', 'A-Z'], value = 'Relevance', multiselect = False, label = 'Sort By')
|
199 |
+
max_return = gr.Dropdown(choices = ['10', '25', '50', '75', '100', '250', '500', '1000', '5000', '10000', 'All'], value = '50', multiselect = False, label = 'No. of Results to Return (Total: 0)')
|
200 |
with gr.Row():
|
201 |
search_button = gr.Button(value="Search!")
|
202 |
with gr.Row():
|
203 |
output_df = gr.HTML()
|
204 |
back_top_btn = gr.HTML(back_to_top_btn_html)
|
205 |
+
search_button.click(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search], outputs=[output_df, max_return])
|
206 |
+
search_prompt.submit(search_index, inputs=[search_prompt, shared_drive, key_stage, sort_by, max_return, user_num, title_search], outputs=[output_df, max_return])
|
207 |
search_button.click(search_logging, inputs=[search_prompt], outputs=None)
|
208 |
search_prompt.submit(search_logging, inputs=[search_prompt], outputs=None)
|
209 |
|