|
|
|
|
@ -196,9 +196,10 @@ def search_user(search_for, engine): |
|
|
|
|
def main(): |
|
|
|
|
engine = create_engine('sqlite:///db.sqlite') |
|
|
|
|
|
|
|
|
|
#global params |
|
|
|
|
# Create query_params class and set empty parameters. |
|
|
|
|
params = Params(st.experimental_get_query_params()) |
|
|
|
|
|
|
|
|
|
# Let user chose what categorie to search in. |
|
|
|
|
categories = ['Meddelanden', 'Användare'] |
|
|
|
|
if params.category != '': |
|
|
|
|
index_category = categories.index(params.category[0]) |
|
|
|
|
@ -207,6 +208,7 @@ def main(): |
|
|
|
|
search_category = st.selectbox('Vad vill du söka efter?', categories, index_category, on_change=reset_q) |
|
|
|
|
params.update('category', search_category) |
|
|
|
|
|
|
|
|
|
# Let user chose what words to search for. |
|
|
|
|
if params.q != '': |
|
|
|
|
placeholder=params.q[0] |
|
|
|
|
else: |
|
|
|
|
@ -214,30 +216,20 @@ def main(): |
|
|
|
|
|
|
|
|
|
search_for = st.text_input('Vad vill du söka efter?', placeholder=placeholder, ) |
|
|
|
|
|
|
|
|
|
# Set search input from params if nothing else is input. |
|
|
|
|
# This is the case when the user is coming from an url with q param. |
|
|
|
|
if search_for == '' and params.q != '': |
|
|
|
|
search_for = params.q[0] |
|
|
|
|
|
|
|
|
|
# Start the search. |
|
|
|
|
if search_for != '': |
|
|
|
|
params.update('q', search_for) |
|
|
|
|
search_for.replace('å', '?').replace('ä', '?').replace('ö', '?') |
|
|
|
|
search_for.replace('å', '?').replace('ä', '?').replace('ö', '?') #TODO Do better. |
|
|
|
|
|
|
|
|
|
#* Sök meddelanden |
|
|
|
|
#* Search message |
|
|
|
|
if search_category == 'Meddelanden': |
|
|
|
|
search_messages(search_for, engine) |
|
|
|
|
|
|
|
|
|
# m1, m2, body, senddate_str = st.columns([1, 1, 5, 1]) |
|
|
|
|
# for row in data['df'].iterrows(): |
|
|
|
|
# row = row[1] |
|
|
|
|
# with m1: |
|
|
|
|
# row['m1'] |
|
|
|
|
# with m2: |
|
|
|
|
# row['m2'] |
|
|
|
|
# with body: |
|
|
|
|
# row['body'] |
|
|
|
|
# with senddate_str: |
|
|
|
|
# row['senddate_str'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#* Sök användare |
|
|
|
|
elif search_category == 'Användare': |
|
|
|
|
search_user(search_for, engine) |
|
|
|
|
|