ansonphong / postworld

Wordpress Theme Development Framework
GNU General Public License v2.0
7 stars 0 forks source link

get_user_points_voted_to_posts() Defunct Due to DB Schema Change #72

Closed ansonphong closed 11 years ago

ansonphong commented 11 years ago

Hi Haidy, I found a small bug which makes the in the points functions not work. This is due to a schema change that happened several weeks ago, where we removed author_id which was redundant in wp_postworld_post_meta.

As a result these errors were found.

On calculate_user_post_points(), this error is produced:

WordPress database error: [Unknown column 'author_id' in 'field list']
select post_id,author_id ,sum(post_points) as total_points, wp_posts.post_type from wp_postworld_post_meta left join wp_posts on (wp_posts.ID = wp_postworld_post_meta.post_id AND wp_posts.post_author = wp_postworld_post_meta.author_id) group by post_type

On get_user_points_voted_to_posts() this error is produced:

WordPress database error: [Unknown column 'author_id' in 'where clause']
SELECT SUM(post_points) as total_points FROM wp_postworld_post_meta Where author_id=1
hmikhail commented 11 years ago

I'm wondering why was author_id column removed from wp_postworld_post_meta .I think it should be added to this table instead of wp_postworld_post_points as we agreed in a previous e-mail. Let me know if you want me to change it.

ansonphong commented 11 years ago

This is an interesting idea. Do you think that joining the table with wp_posts in the query will have significant change of performance?

It would be redundant data, but if it helps performance significantly then its a good idea.

If we re-add author id to the table, we'll also want to add a function in pw_update/insert_post which keeps the value updated, as there is an option for admins to change the author of a post after it's created.

What do you think?

On Saturday, November 2, 2013, hmikhail wrote:

I'm wondering why was author_id column removed from wp_postworld_post_meta .I think it should be added to this table instead of wp_postworld_post_points as we agreed in a previous e-mail. Let me know if you want me to change it.

— Reply to this email directly or view it on GitHubhttps://github.com/phongmedia/postworld/issues/72#issuecomment-27629447 .

hmikhail commented 11 years ago

I think this is better than doing the join. And adding author_id to post_meta is less redundant than adding it to post_points. I can add the change to update/insert post easily as it was partially implemented in the old code.

ansonphong commented 11 years ago

Right I understand.

Yes you can go ahead and update the schema as you suggested, and have a review of the other functions to see if anything else would be affected.

Thanks

On Saturday, November 2, 2013, hmikhail wrote:

I think this is better than doing the join. And adding author_id to post_meta is less redundant than adding it to post_points. I can add the change to update/insert post easily as it was partially implemented in the old code.

— Reply to this email directly or view it on GitHubhttps://github.com/phongmedia/postworld/issues/72#issuecomment-27631761 .