mirror of
				https://github.com/simon987/opendirectories-bot-2.git
				synced 2025-11-03 22:56:52 +00:00 
			
		
		
		
	Don't display result table when there is no results
This commit is contained in:
		
							parent
							
								
									c0891aa5e1
								
							
						
					
					
						commit
						faf0eee0fd
					
				
							
								
								
									
										1
									
								
								od_database
									
									
									
									
									
										Submodule
									
								
							
							
								
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								od_database
									
									
									
									
									
										Submodule
									
								
							@ -0,0 +1 @@
 | 
			
		||||
Subproject commit 1ff1e039f5aed3394cd9ff0f0e6e4b88d3b0618e
 | 
			
		||||
@ -90,33 +90,36 @@ class OdDatabase:
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def format_search_hits(hits, query):
 | 
			
		||||
 | 
			
		||||
        message = str(hits["hits"]["total"]) + " matches found in " + str(hits["took"]) + "ms for query `" + query + "`:    \n\n"
 | 
			
		||||
        message += "File | Size | Date    \n"
 | 
			
		||||
        message += ":-- | :-- | --:    \n"
 | 
			
		||||
        message = str(hits["hits"]["total"]) + " matches found in " + str(hits["took"]) + "ms for query `" + query + "`"
 | 
			
		||||
        if hits["hits"]["total"] > 0:
 | 
			
		||||
            message += ":    \n\n"
 | 
			
		||||
            message += ":-- | :-- | --:    \n"
 | 
			
		||||
 | 
			
		||||
        for hit in hits["hits"]["hits"]:
 | 
			
		||||
            src = hit["_source"]
 | 
			
		||||
            for hit in hits["hits"]["hits"]:
 | 
			
		||||
                src = hit["_source"]
 | 
			
		||||
 | 
			
		||||
            # File name highlight
 | 
			
		||||
            if "name" in hit["highlight"]:
 | 
			
		||||
                hl_name = format_highlight(hit["highlight"]["name"][0])
 | 
			
		||||
            elif "name.nGram" in hit["highlight"]:
 | 
			
		||||
                hl_name = format_highlight(hit["highlight"]["name.nGram"][0])
 | 
			
		||||
            else:
 | 
			
		||||
                hl_name = src["name"]
 | 
			
		||||
                # File name highlight
 | 
			
		||||
                if "name" in hit["highlight"]:
 | 
			
		||||
                    hl_name = format_highlight(hit["highlight"]["name"][0])
 | 
			
		||||
                elif "name.nGram" in hit["highlight"]:
 | 
			
		||||
                    hl_name = format_highlight(hit["highlight"]["name.nGram"][0])
 | 
			
		||||
                else:
 | 
			
		||||
                    hl_name = src["name"]
 | 
			
		||||
 | 
			
		||||
            # Path highlight
 | 
			
		||||
            if "path" in hit["highlight"]:
 | 
			
		||||
                hl_path = format_highlight(hit["highlight"]["path"][0])
 | 
			
		||||
            else:
 | 
			
		||||
                hl_path = src["path"]
 | 
			
		||||
            hl_path = truncate_path(hl_path, 65)
 | 
			
		||||
            hl_path += "/" if hl_path else ""
 | 
			
		||||
                # Path highlight
 | 
			
		||||
                if "path" in hit["highlight"]:
 | 
			
		||||
                    hl_path = format_highlight(hit["highlight"]["path"][0])
 | 
			
		||||
                else:
 | 
			
		||||
                    hl_path = src["path"]
 | 
			
		||||
                hl_path = truncate_path(hl_path, 65)
 | 
			
		||||
                hl_path += "/" if hl_path else ""
 | 
			
		||||
 | 
			
		||||
            message += "[" + src["website_url"] + "](https://od-db.the-eye.eu/website/" + str(src["website_id"]) + "/)" + hl_path
 | 
			
		||||
            message += hl_name + ("." if src["ext"] else "") + src["ext"] + " | "
 | 
			
		||||
            message += humanfriendly.format_size(src["size"]) + " | "
 | 
			
		||||
            message += time.strftime("%Y-%m-%d", time.gmtime(src["mtime"])) + "    \n"
 | 
			
		||||
                message += "[" + src["website_url"] + "](https://od-db.the-eye.eu/website/" + str(src["website_id"]) + "/)" + hl_path
 | 
			
		||||
                message += hl_name + ("." if src["ext"] else "") + src["ext"] + " | "
 | 
			
		||||
                message += humanfriendly.format_size(src["size"]) + " | "
 | 
			
		||||
                message += time.strftime("%Y-%m-%d", time.gmtime(src["mtime"])) + "    \n"
 | 
			
		||||
        else:
 | 
			
		||||
            message += "\n"
 | 
			
		||||
 | 
			
		||||
        message += "\n[More results for this query](https://od-db.the-eye.eu/search?q=" + query + ") |" \
 | 
			
		||||
                   " [OD-Database](https://od-db.the-eye.eu/)"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user