<s> from autumn . db . query import Query <EOL> def search ( profile , query , begin , page_size ) : <EOL> return Query . sql ( <EOL> """<STR_LIT>""" , <EOL> ( query , query , profile , <EOL> '<STR_LIT>' + query + '<STR_LIT>' , '<STR_LIT>' + query + '<STR_LIT>' , <EOL> begin , page_size ) ) <EOL> def dashboard_feed ( profile , begin , page_size , sort_type , read_all_mode , <EOL> specific_feed , just_local_feed , local_entry = None , remote_entry = None , <EOL> spam = False , favorite = False , comments = False , external = None , query = None , <EOL> from_local_date = None , from_remote_date = None ) : <EOL> content_local_restrict = "<STR_LIT>" <EOL> content_remote_restrict = "<STR_LIT>" <EOL> parameters = [ profile , profile ] <EOL> just_remote_feed = False <EOL> sort_query = '<STR_LIT>' <EOL> if sort_type == '<STR_LIT>' : <EOL> sort_query = '<STR_LIT>' <EOL> if specific_feed : <EOL> content_remote_restrict += """<STR_LIT>""" <EOL> parameters . append ( specific_feed ) <EOL> if local_entry : <EOL> content_local_restrict += """<STR_LIT>""" <EOL> parameters . append ( local_entry ) <EOL> if remote_entry : <EOL> content_remote_restrict += """<STR_LIT>""" <EOL> parameters . append ( remote_entry ) <EOL> elif begin != <NUM_LIT:0> : <EOL> comparison = '<STR_LIT>' if sort_type == '<STR_LIT>' else '<STR_LIT>' <EOL> if from_local_date : <EOL> content_local_restrict += ( """<STR_LIT>""" + <EOL> comparison + """<STR_LIT>""" ) <EOL> parameters . append ( from_local_date ) <EOL> if from_remote_date : <EOL> content_remote_restrict += ( """<STR_LIT>""" + <EOL> comparison + """<STR_LIT>""" ) <EOL> parameters . append ( from_remote_date ) <EOL> elif ( not spam and not favorite and not comments and not query <EOL> and read_all_mode == <NUM_LIT:0> ) : <EOL> content_remote_restrict += """<STR_LIT>""" <EOL> if spam : <EOL> just_remote_feed = True <EOL> content_remote_restrict += """<STR_LIT>""" <EOL> if favorite : <EOL> just_remote_feed = True <EOL> content_remote_restrict += """<STR_LIT>""" <EOL> if external : <EOL> just_remote_feed = True <EOL> content_remote_restrict += """<STR_LIT>""" <EOL> parameters . append ( external ) <EOL> if comments : <EOL> just_remote_feed = True <EOL> content_remote_restrict += """<STR_LIT>""" <EOL> parameters . append ( '<STR_LIT>' ) <EOL> elif ( not just_local_feed and not local_entry and not remote_entry <EOL> and not external <EOL> and not favorite and not spam and not comments and not query ) : <EOL> content_remote_restrict += """<STR_LIT>""" <EOL> parameters . append ( '<STR_LIT>' ) <EOL> if query : <EOL> just_remote_feed = True <EOL> content_remote_restrict += """<STR_LIT>""" <EOL> parameters . append ( '<STR_LIT:%>' + query + '<STR_LIT:%>' ) <EOL> parameters . append ( '<STR_LIT:%>' + query + '<STR_LIT:%>' ) <EOL> parameters += [ begin , page_size ] <EOL> local_query = """<STR_LIT>""" + content_local_restrict + """<STR_LIT>""" + sort_query + """<STR_LIT:)>""" <EOL> remote_query = """<STR_LIT>""" + content_remote_restrict + """<STR_LIT>""" + sort_query + """<STR_LIT>""" + sort_query <EOL> limit_fragment = """<STR_LIT>""" <EOL> if not just_remote_feed and ( just_local_feed or local_entry ) : <EOL> parameters . pop ( <NUM_LIT:0> ) <EOL> return Query . sql ( local_query + limit_fragment , parameters ) <EOL> if just_remote_feed or specific_feed or remote_entry : <EOL> parameters . pop ( <NUM_LIT:0> ) <EOL> return Query . sql ( remote_query + limit_fragment , parameters ) <EOL> return Query . sql ( local_query + """<STR_LIT>""" + remote_query + limit_fragment , <EOL> parameters ) </s>
