A potential lil fork starting with a hack'd-on trust system


(leathan) #1

My question:
Are what users like stored somewhere? Can I retrieve those values via redis or postresql?

My goal:
Enable W3C compliant cryptographic micro-transactions via likes to build helpful reputation/trust algorithms.
If your interested in the details read more here.

My plan of action
First I quickly scanned the postresql databases and then the redis database. Now I’m quite a noob when it comes to psql/redis/ruby. So it may take me a while to do this on my own but at least ill learn some new syntax. and Discourse code is insanely beautiful.

More
I only probed around for a couple hours but i figured if I’m to prod around more i might as well open a topic here and ask. Im quite sure this database piggyback strategy would just be a quick HACK and that eventually id have to modify the underlying ruby.

P.S. Thanks again for writing this beautiful beautiful source code.


(Benjamin Kampmann) #2

If you go into the rails console (for e.g. in Vagrant) and then execute

UserAction.where(:action_type => UserAction::LIKE)

You will get a List of all the UserAction-Type models that refer to someone liking posts:

=> [#<UserAction id: 364, action_type: 1, user_id: 23, target_topic_id: 48, target_post_id: 70, target_user_id: nil, acting_user_id: 23, created_at: "2013-02-04 19:49:56", updated_at: "2013-02-04 19:49:56">,
 #<UserAction id: 266, action_type: 1, user_id: 11, target_topic_id: 26, target_post_id: 44, target_user_id: nil, acting_user_id: 11, created_at: "2013-02-01 16:56:34", updated_at: "2013-02-01 16:56:34">,
 #<UserAction id: 284, action_type: 1, user_id: 20, target_topic_id: 36, target_post_id: 53, target_user_id: nil, acting_user_id: 20, created_at: "2013-02-04 18:00:35", updated_at: "2013-02-04 18:00:35">,
 #<UserAction id: 147, action_type: 1, user_id: 9, target_topic_id: 26, target_post_id: 29, target_user_id: nil, acting_user_id: 9, created_at: "2013-01-31 22:16:50", updated_at: "2013-01-31 22:16:50">,
 #<UserAction id: 278, action_type: 1, user_id: 7, target_topic_id: 27, target_post_id: 28, target_user_id: nil, acting_user_id: 7, created_at: "2013-02-01 18:57:00", updated_at: "2013-02-01 18:57:00">,
 #<UserAction id: 375, action_type: 1, user_id: 23, target_topic_id: 48, target_post_id: 73, target_user_id: nil, acting_user_id: 23, created_at: "2013-02-04 19:57:43", updated_at: "2013-02-04 19:57:43">,
 #<UserAction id: 295, action_type: 1, user_id: 22, target_topic_id: 27, target_post_id: 43, target_user_id: nil, acting_user_id: 22, created_at: "2013-02-04 18:21:02", updated_at: "2013-02-04 18:21:02">]

Attention this might be potentially huge on bigger installations!

If you want it more raw, the corresponding SQL for this query is:

SELECT "user_actions".* FROM "user_actions"  WHERE "user_actions"."action_type" = 1

Enjoy.


(leathan) #3

Appears to be exactly what i wanted. However I dont even have that table name =( Im checking the postresql db’s. Right?


(Benjamin Kampmann) #4

Are you sure you are on the right database of a rather recent version of discourse? Unless you have messed with your installation, this has to be there (or Discourse won’t run actually)…


(leathan) #5

Aha it must be the discourse version. I needed to use an older version because I installed on a VPS which isnt properly sandboxed and hence i cant upgrade the kernel. I must use the 2.2 kernal. Which cant quite run docker. Bitnami instalation to be specific (its only temporary untill i get a sandboxed VPS) When i cd into the discourse folder I see three potential database mediums.

sqlite
postresql
redis

However i checked all of them and cant really see a spot where the user likes are stored… i certainly didnt find a table named user_actions. Under the postresql databases for example i see all the table names start with

pg_

I will install the most recent version of discourse right now on my local machine. However Im hoping I can get this done on the old version too though. Thanks alot for your time btw too :slight_smile:


(leathan) #6

You can see my instalation at http://forum.mubot.com

Maybe im just noobing something up, but I cant find a table name of “user_actions” in the postresql databases.


(leathan) #7

Figured it out.

Thanks so much man!

I admire your guys’ code and hope not to butcher it too much.