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
 | 
					    @staticmethod
 | 
				
			||||||
    def format_search_hits(hits, query):
 | 
					    def format_search_hits(hits, query):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        message = str(hits["hits"]["total"]) + " matches found in " + str(hits["took"]) + "ms for query `" + query + "`:    \n\n"
 | 
					        message = str(hits["hits"]["total"]) + " matches found in " + str(hits["took"]) + "ms for query `" + query + "`"
 | 
				
			||||||
        message += "File | Size | Date    \n"
 | 
					        if hits["hits"]["total"] > 0:
 | 
				
			||||||
        message += ":-- | :-- | --:    \n"
 | 
					            message += ":    \n\n"
 | 
				
			||||||
 | 
					            message += ":-- | :-- | --:    \n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for hit in hits["hits"]["hits"]:
 | 
					            for hit in hits["hits"]["hits"]:
 | 
				
			||||||
            src = hit["_source"]
 | 
					                src = hit["_source"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # File name highlight
 | 
					                # File name highlight
 | 
				
			||||||
            if "name" in hit["highlight"]:
 | 
					                if "name" in hit["highlight"]:
 | 
				
			||||||
                hl_name = format_highlight(hit["highlight"]["name"][0])
 | 
					                    hl_name = format_highlight(hit["highlight"]["name"][0])
 | 
				
			||||||
            elif "name.nGram" in hit["highlight"]:
 | 
					                elif "name.nGram" in hit["highlight"]:
 | 
				
			||||||
                hl_name = format_highlight(hit["highlight"]["name.nGram"][0])
 | 
					                    hl_name = format_highlight(hit["highlight"]["name.nGram"][0])
 | 
				
			||||||
            else:
 | 
					                else:
 | 
				
			||||||
                hl_name = src["name"]
 | 
					                    hl_name = src["name"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # Path highlight
 | 
					                # Path highlight
 | 
				
			||||||
            if "path" in hit["highlight"]:
 | 
					                if "path" in hit["highlight"]:
 | 
				
			||||||
                hl_path = format_highlight(hit["highlight"]["path"][0])
 | 
					                    hl_path = format_highlight(hit["highlight"]["path"][0])
 | 
				
			||||||
            else:
 | 
					                else:
 | 
				
			||||||
                hl_path = src["path"]
 | 
					                    hl_path = src["path"]
 | 
				
			||||||
            hl_path = truncate_path(hl_path, 65)
 | 
					                hl_path = truncate_path(hl_path, 65)
 | 
				
			||||||
            hl_path += "/" if hl_path else ""
 | 
					                hl_path += "/" if hl_path else ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            message += "[" + src["website_url"] + "](https://od-db.the-eye.eu/website/" + str(src["website_id"]) + "/)" + hl_path
 | 
					                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 += hl_name + ("." if src["ext"] else "") + src["ext"] + " | "
 | 
				
			||||||
            message += humanfriendly.format_size(src["size"]) + " | "
 | 
					                message += humanfriendly.format_size(src["size"]) + " | "
 | 
				
			||||||
            message += time.strftime("%Y-%m-%d", time.gmtime(src["mtime"])) + "    \n"
 | 
					                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 + ") |" \
 | 
					        message += "\n[More results for this query](https://od-db.the-eye.eu/search?q=" + query + ") |" \
 | 
				
			||||||
                   " [OD-Database](https://od-db.the-eye.eu/)"
 | 
					                   " [OD-Database](https://od-db.the-eye.eu/)"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user