mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Viwe fix
This commit is contained in:
@@ -1965,9 +1965,10 @@ async def parametry_muzyki_mego_ludu(
|
||||
logger.info(exce)
|
||||
|
||||
class DoSearchView(discord.ui.View):
|
||||
def __init__(self,*args, **kwargs) -> None:
|
||||
def __init__(self, uuid, result_list, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
self.row1 = "Test"
|
||||
self.uuid = uuid
|
||||
self.result_list = result_list
|
||||
@discord.ui.button(label="Nastepna strona", style=discord.ButtonStyle.primary, row=0)
|
||||
async def next_callback(self, interaction, button):
|
||||
#emoji = await ctx.guild.fetch_emoji(id)
|
||||
@@ -2008,11 +2009,13 @@ async def wyszukaj_linki_do_dokumentow(ctx):
|
||||
#4 zwroc 4 wyniki od librariana
|
||||
#5 przyciski przy każdym wierszu pozwalają sprawdzić czy plik istnieje na scihubie - jeśli tak podaje link do sciagniecia
|
||||
#6 ostatni wiersz to dalej, wróć, skasuj, zaciagnij kolejne wyniki (jeśli jest ich więcej niż 1000)
|
||||
result_view = DoSearchView()
|
||||
result_view = DoSearchView(uuid=str(query_uuid), result_list=query_response.json(["data"]))
|
||||
resulttab = []
|
||||
resultlink = []
|
||||
logger.info(query_response.json())
|
||||
for item in query_response.json()["data"]:
|
||||
hit, fetched, total, uuid_chk = query_response.json()["data"][0]
|
||||
answer = query_response.json()["data"][1]
|
||||
|
||||
for item in answer:
|
||||
resulttab.append(str(item["title"]))
|
||||
item_link = "https://sci-hub.se/" + str(item["DOI"])
|
||||
resultlink.append(item_link)
|
||||
@@ -2025,9 +2028,9 @@ async def wyszukaj_linki_do_dokumentow(ctx):
|
||||
logger.info(url)
|
||||
temp_label = str(resulttab[i])
|
||||
temp_label = temp_label.strip("[']")
|
||||
result_view.add_item(discord.ui.Button(label = str(temp_label[0:79], row = i+1,url=url)))
|
||||
result_view.add_item(discord.ui.Button(label = str(temp_label[0:79]), row = i+1,url=url))
|
||||
|
||||
labelka = "Wyniki wyszukiwania dla: " + str(query)[30:] # ile znaleziono artykułów w ogóle, ile zostało po refine
|
||||
labelka = "Wyniki wyszukiwania dla: " + str(query)[30:] + f'\nWszystkich {total} sprawdzonych: {fetched} znalezionych: {hit} '# ile znaleziono artykułów w ogóle, ile zostało po refine
|
||||
await ctx.send(labelka, view=result_view) # Send a message with our View class that contains the button
|
||||
|
||||
|
||||
|
||||
@@ -32,13 +32,14 @@ class Librarian(object):
|
||||
authTokens = netrc_mod.authenticators("crossref")
|
||||
self.cr = Crossref(mailto=authTokens[0])
|
||||
self.limit = 1000
|
||||
self.fetched = 0
|
||||
self.hit = 0
|
||||
self.total = 0
|
||||
|
||||
def search_crossref(self, query, uuid):
|
||||
search_result_from_cr = self.cr.works(query = query, limit = self.limit)
|
||||
print("Total results")
|
||||
print(search_result_from_cr['message']['total-results'])
|
||||
print("Fetched")
|
||||
print(len(search_result_from_cr['message']['items']))
|
||||
self.total = search_result_from_cr['message']['total-results']
|
||||
self.fetched = len(search_result_from_cr['message']['items'])
|
||||
#add to sql with UUID
|
||||
#sql row - title, doi, author, uuid, last retrieved, is_available
|
||||
with open("results.json", "r+", encoding="UTF-8") as data_file:
|
||||
@@ -102,7 +103,7 @@ class Librarian(object):
|
||||
print(item["title"])
|
||||
time.sleep(0.01)
|
||||
print("Existing hits")
|
||||
print(len(refined_result))
|
||||
self.hit = len(refined_result)
|
||||
return refined_result
|
||||
|
||||
def answer_query(self, query, uuid):
|
||||
@@ -161,6 +162,8 @@ def query_database():
|
||||
cl = Librarian()
|
||||
answer_data = cl.answer_query(record["query"], record["UUID"])
|
||||
app.logger.info(answer_data)
|
||||
summary = (cl.hit,cl.fetched, cl.total, record["UUID"])
|
||||
answer_data = (summary,answer_data)
|
||||
return_data = (
|
||||
jsonify(isError=False, message="Success", statusCode=200, data=answer_data),
|
||||
200,
|
||||
|
||||
Reference in New Issue
Block a user