How to get professions on world of warcraft vanilla's addon? - api

I'm creating an AddOn for a private server of World of Warcraft 1.12.1/Classic/Vanilla and I need to check the user's professions.
The information I got was the APIs GetProfessions() and GetProfessionInfo() but I can't find out how to use them.
I wanna have a variable for each profession.
It's something like this:
prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions()
Profession1 = GetProfessionInfo(prof1)
Profession2 = GetProfessionInfo(prof2)
Profession3 = GetProfessionInfo(archaeology)
Profession4 = GetProfessionInfo(fishing)
Profession5 = GetProfessionInfo(cooking)
Profession6 = GetProfessionInfo(firstAid)

Quick glance shows there are no special tradeskill functions in API in 1.12.1. AFAIR professions were just regular entries in the spellbook back then. As such you can iterate over spellbook with GetSpellName and check that either first return matches name of known profession or second return matches name of a known profession rank.
Additional info on each profession can be retrieved with GetTradeSkillLine, but only when this profession is opened in tradeskill window (i.e. window where you see list of items to craft).

If I'm understanding this correctly, GetProfessions() returns a table. You could always try a different way around the problem, like so:
professions = GetProfessions()
Profession1 = GetProfessionInfo(professions[1])
Profession2 = GetProfessionInfo(professions[2])
Profession3 = GetProfessionInfo(professions[3])
Profession4 = GetProfessionInfo(professions[4])
Profession5 = GetProfessionInfo(professions[5])
Profession6 = GetProfessionInfo(professions[6])
I'm not sure if this will solve your problem, but I figured I could weigh in my opinion. I have never done anything with World of Warcraft.

Related

Ruby on Rails ActiveRecord query select only column string field value with where clause?

I was wondering if there is a way to use a select statement with a where clause similar to this way that does not seem to work for me in Ruby version 2.0/Rails 4.0 trying to retrieve a single record string value of a city where the building name is a certain name:
building_city = Building.select(:city).where(building_name: building).uniq
I have also tried:
building_city = Building.select(:city).where(building_name: building).distinct
Currently I have my code working like this:
building_city = Building.where(building_name: building).first
This grabs an entire Building object, and then I can call the city by doing a:
building_city.city
This works fine with what I am trying to achieve, but I was wondering if there is a smarter way to do this. Specifically, I was wondering if there is a way to grab only the string value of a city where the building name equals a certain building and store it into a variable?
Any help/advice is greatly appreciated! :)
Are you perhaps looking for pluck? Something like:
cities = Building.where(building_name: building).uniq.pluck(:city)
That will perform this SQL:
select distinct city from buildings where building_name = '...'
and give you the cities as an array of strings. You'll still get an array but a quick first call will take care of that if you're certain that there will only be one entry.
building_city = Building.select(:city, :building_name).where(building_name: building).uniq — you need to include the building_name
city = Building.where(building_name: building).pick(:city)
Rails 6 introduced pick method with works like where(..).pluck(..).first. Docs

How to get the latest papers from pubmed

This is a bit of a specific question, but somebody must have done this before. I would like to get the latest papers from pubmed. Not papers about a certain subjects, but all of them. I thought to query depending on modification date (mdat). I use biopython.py and my code looks like this
handle = Entrez.egquery(mindate='2015/01/10',maxdate='2017/02/19',datetype='mdat')
results = Entrez.read(handle)
for row in results["eGQueryResult"]:
if row["DbName"]=="nuccore":
print(row["Count"])
However, this results in zero papers. If I add term='cancer' I get heaps of papers. So the query seems to need the term keyword... but I want all papers, not papers on a certain subjects. Any ideas how to do this?
thanks
carl
term is a required parameter, so you can't omit it in your call to Entrez.egquery.
If you need all the papers within a specified timeframe, you will probably need a local copy of MEDLINE and PubMed Central:
For MEDLINE, this involves getting a license. For PubMed Central, you
can download the Open Access subset without a license by ftp.
EDIT for python3. The idea is that the latest pubmed id is the same thing as the latest paper (which I'm not sure is true). Basically does a binary search for the latest PMID, then gives a list of the n most recent. This does not look at dates, and only returns PMIDs.
There is an issue however where not all PMIDs exist, for example https://pubmed.ncbi.nlm.nih.gov/34078719/ exists, https://pubmed.ncbi.nlm.nih.gov/34078720/ does not (retraction?), and https://pubmed.ncbi.nlm.nih.gov/34078721/ exists. This ruins the binary search since it can't know if it's found a PMID that hasn't been used yet, or if it has found one that has previously existed.
CODE:
import urllib
def pmid_exists(pmid):
url_stem = 'https://www.ncbi.nlm.nih.gov/pubmed/'
query = url_stem+str(pmid)
try:
request = urllib.request.urlopen(query)
return True
except urllib.error.HTTPError:
return False
def get_latest_pmid(guess = 27239557, _min_guess=None, _max_guess=None):
#print(_min_guess,'<=',guess,'<=',_max_guess)
if _min_guess and _max_guess and _max_guess-_min_guess <= 1:
#recursive base case, this guess must be the largest PMID
return guess
elif pmid_exists(guess):
#guess PMID exists, search for larger ids
_min_guess = guess
next_guess = (_min_guess+_max_guess)//2 if _max_guess else guess*2
else:
#guess PMID does not exist, search for smaller ids
_max_guess = guess
next_guess = (_min_guess+_max_guess)//2 if _min_guess else guess//2
return get_latest_pmid(next_guess, _min_guess, _max_guess)
#Start of program
n = 5
latest_pmid = get_latest_pmid()
most_recent_n_pmids = range(latest_pmid-n, latest_pmid)
print(most_recent_n_pmids)
OUTPUT:
[28245638, 28245639, 28245640, 28245641, 28245642]

Best way to query postgres db from django to list all users (tab1) which have active book borrows (tab2)?

I have a simple application in Django. The simple logic is kind of book library.
Tab1. stores the users:
class Readers(Model):
last_name = CharField(...)
first_name = CharField(...)
Tab2. stores the book borrows:
class BookBorrows(Model):
index = IntegerField(db_index=True, ...)
reader = ForeignKey('Reader', ...)
book = ForeignKey('Book', ...)
active = BooleanField(...)
I am struggling to figure out what is the proper solution to get:
List of all Readers with at least one borrowed book (the field active==True).
List of all Readers without any currently borrowed book (the field active==False).
After some serche I am thinking about django .raw('QUERY ...') or maybe is there a more django-friendly way to achieve this?
P.S.:this is my first question posted to SO.
reader_ids_with_book = BookBorrows.objects.filter(active=True).values_list(
'reader_id', flat=True
)
readers_without_book = Readers.objects.exclude(id__in=list(reader_ids_with_book))
first query gives you the valuelist queryset of users who borrowed at least one book and you can use this in order to find out other users who didnot borrow anything yet

read all document by using particular category name using alfresco search.luceneSearch or search.lib.js

Category Name
|
Geograpy (8)
Study Db (18)
i am implement my own advance search in alfresco. i need to read all files which related with particular category.
example:
if there is 20 file under geograpy, lucene query should read particular document under search key word "banana".
Further explanation -
I am using search.lib.js to search. I would like to analyze the result to find out to which category the documents belong to. For example I would like to know how many documents belong to the category under Languages and the subcategories. I experimented with the Classification API but I don't get the result I want. Any Idea how to go through the result to get the category name of each document?
is there any simple method like node.properties["cm:creator"]?
thanks
janaka
I think you should specify more your question:
Are you using cm:content or a customized content?
Are you going to search the keyword inside the content of the file? or are you going to search the keyword in a specific metadata(s)?
Do you want to create a webscript (java or javascript)?
One thing to take in consideration:
if you use +PATH:"cm:generalclassifiable/...." for the categorization in your lucene queries, the performance will be slow (following my experince)
You can use for example the next query to find all nodes at any depth below /cm:Languages:
var results = search.luceneSearch("+PATH:\"cm:generalclassifiable/cm:Languages//*\");
Take a look to this url: https://wiki.alfresco.com/wiki/Search#Path_Queries
Once you have all the elements, you can loop all, and get to which category below. Of course you need to create some counter per each category/subcategory:
for(i = 0; i < results.length; i++){
var node = results[i];
var categoryNodeRef = node.properties["cm:categories"];
var categoryDesc = categoryNodeRef.properties["cm:description"];
var categoryName = categoryNodeRef.properties["cm:name"];
}
This is not exactly the solution, but can be a useful idea to start.
Sorry if it's not what you're asking for, I have just arrived from my holidays.

NHibernate many to many backward query

This is a question asked with an ignorance of thew subject matter, but i have searche dlong and hard so i hope this will not be too painful.
I'm using nhibernate for a many to many query.
My objects map (not my design, not getting changed any time soon):
Computer (id, name, etc...) -> (mapping table ) -> Config ( id, key, value )
One computer may have many configs, any config may belong to multiple computers. i can read a computer out fine and the list(bag) member is populated fine.
I then want to find a computer that has numerous configs.
E.g. all computers that have:
OS : Windows
CPU : 2GHz
etc.
Any assistance on how I could put this into a criteria query would be greatly appreciated. I've done some of the basics but wrapping my head around this is proving hard work.
Cheers for any assistance,
Rob.
If the parameters are always the same, use a query like the following:
var computers = session.CreateQuery(
#"select c
from Computer c
inner join c.Configurations as osconfig
inner join c.Configurations as cpuconfig
where
osconfig.Name = 'OS'
and osconfig.Value = :os
and cpuconfig.Name = 'CPU'
and cpuconfig.Value = :cpu")
.SetString("os", "Windows")
.SetString("cpu", "2GHz")
.List<Computer>();
If you mapped it as a map, you can even do something like this:
var computers = session.CreateQuery(
#"select c
from Computer c
where
c.Configurations['OS'] = :os
and c.Configurations['CPU'] = :cpu")
.SetString("os", "Windows")
.SetString("cpu", "2GHz")
.List<Computer>();
If the parameters are always different, use criteria to add them dynamically.