inpho / inphosite

The InPhO API
https://inphoproject.org
15 stars 5 forks source link

influence data is not being properly pulled/displayed #193

Closed colinallen closed 4 years ago

colinallen commented 6 years ago

We are not displaying info from the database

E.g., if you go to Frances Hutcheson (https://www.inphoproject.org/thinker/3261) it says we have no data.

But if you check via sql we have:

MariaDB [seponto]> select * from thinker_has_influenced where thinker1_id=3261;
+-------------+-------------------+-------------+----------------+--------+
| thinker1_id | thinker1_name     | thinker2_id | thinker2_name  | source |
+-------------+-------------------+-------------+----------------+--------+
|        3261 | Francis Hutcheson |        2633 | Jeremy Bentham |      0 |
|        3261 | Francis Hutcheson |        2737 | Joseph Butler  |      0 |
|        3261 | Francis Hutcheson |        3256 | David Hume     |      0 |
|        3261 | Francis Hutcheson |        3345 | Immanuel Kant  |      0 |
|        3261 | Francis Hutcheson |        3911 | Adam Smith     |      0 |
+-------------+-------------------+-------------+----------------+--------+
JaimieMurdock commented 6 years ago

Did you ever get the main inpho library running on your laptop?

Just asking because it might make some debugging easier and not play with the production system, although you'd be playing with the production database. Remember that the inpho code only operates in Python 2. We also might have to open a hole to your new home internet.

What I would do is use python on the command line and do each of these by hand, or write a little script:

from inpho.model import *
hutcheson = Session.query(Thinker).get(3261)
print(hutcheson.influenced)
print(hutcheson.influenced_by)

This will test if the ORM is configured properly.

The influenced relation is defined in https://github.com/inpho/inpho/blob/master/inpho/model/__init__.py#L387

What needs to happen as a longer-term project is get the SQLAlchemy version upgraded - we are on 0.6.8 and the current version is 1.2.10, with 1.3 coming soon - as part of that, migrating just the db model to be 2/3 dual compatible would make it easier for us long-term.

kirtansakariya commented 6 years ago

I think it may be an issue with the SQL query. I'm looking at entity.js and where it's calling the getattr() method. I think this is a method that is supplied through the makotemplates that we're using because I can't find it in the repo. It won't return the appropriate data for some sections maybe because the SQL query supplied through makotemplates isn't doing exactly what we want it to?

JaimieMurdock commented 6 years ago

Interesting theory.

getattr() is a Python method that essentially replicates the . operator (e.g., str.split()). It allows you to specify an attribute for the part after the dot so that you can programmatically access different attributes.

The better place to start with debugging is going to be in inpho.model, where you should be able to query the entries. A likely missing piece is that our SQL queries are being dynamically written by SQLAlchemy, a library which translates native Python objects into SQL objects.