Thanks for this great module swentel. I just want to make sure of the following. I want to show one random image for every user, and that image must be "randomized" every hour. To do that with Views and your module, I choose to show only 1 image and at Sort Critera, I select Random Seed.

  1. If I want to reset that image every hour, I just select Every hour, leave custom seed at the default (300) and make sure cron runs at least every hour?
  2. In case I want to reset the image every 10 minutes, should I select customize and place 10 under the custom seed?
CommentFileSizeAuthor
#6 449138.patch7.22 KBswentel

Comments

swentel’s picture

Status: Active » Fixed

Hey Juanzo, completely right on both cases, except that it's not really necessary for cron to run - of course, if you are using page caching, it would be necessary to clear that cache for anonymous users and this module doesn't take care of that - and never will too.

artatac’s picture

I am getting the following errorr on rand seed, although random global is ok

warning: pg_query() [function.pg-query]: Query failed: ERROR: function random(integer) does not exist HINT: No function matches the given name and argument types. You may need to add explicit type casts. in /nfs/c02/h03/mnt/30722/domains/aaed.arslanstudios.com/html/includes/database.pgsql.inc on line 139.
user warning: query: SELECT node.nid AS nid, node.type AS node_type, node.vid AS node_vid, node.title AS node_title, node_revisions.teaser AS node_revisions_teaser, node_revisions.format AS node_revisions_format, RANDOM(1241940299) AS _random_seed FROM drupal_node node LEFT JOIN drupal_content_field_image_article node_data_field_image_article ON node.vid = node_data_field_image_article.vid LEFT JOIN drupal_term_node term_node_value_0 ON node.vid = term_node_value_0.vid AND term_node_value_0.tid = 4 LEFT JOIN drupal_term_node term_node_value_1 ON node.vid = term_node_value_1.vid AND term_node_value_1.tid = 3 LEFT JOIN drupal_term_node term_node_value_2 ON node.vid = term_node_value_2.vid AND term_node_value_2.tid = 2 LEFT JOIN drupal_term_node term_node_value_3 ON node.vid = term_node_value_3.vid AND term_node_value_3.tid = 1 LEFT JOIN drupal_node_revisions node_revisions ON node.vid = node_revisions.vid WHERE (node_data_field_image_article.field_image_article_list <> 0) AND (term_node_value_0.tid = 4 OR term_node_value_1.tid = 3 OR term_node_value_2.tid = 2 OR term_node_value_3.tid = 1) ORDER BY _random_seed ASC LIMIT 1 OFFSET 0 in /nfs/c02/h03/mnt/30722/domains/aaed.arslanstudios.com/html/sites/all/modules/views/includes/view.inc on line 731.

swentel’s picture

Status: Fixed » Needs work

Hmm, postgres seems to have a problem with integer then, I'll have to setup a server on my local machine first to start debugging. I'll report back later

develcuy’s picture

Postgresql reference manual says:
random(): random value between 0.0 and 1.0
setseed(dp): set seed for subsequent random() calls (value between 0 and 1.0)
http://www.postgresql.org/docs/8.3/interactive/functions-math.html

Conclusion 1: random(dp) is not provided by postgresql. Just random which is completely different

Testing setseed(dp) and then random():

=> select setseed(0.1); select random();
setseed
---------

(1 row)

random
-------------------
0.727818949148059 <<== This value is constant
(1 row)

Conclusion 2: Is necessary to add a custom function random(dp)

Blessings!

swentel’s picture

@develCuy
So basically, if I'd change

      case 'pgsql':
        $formula = 'RANDOM('. $seed .')';
        break;

to

      case 'pgsql':
        $formula = 'RANDOM()';
        break;

and add db_query('select setseed('. $seed .')') things would work ?

swentel’s picture

Status: Needs work » Needs review
StatusFileSize
new7.22 KB

@artatac and develCuy
can you guys try out the attached patch ? Completely untested here, I hope I can setup a postgres server next week too, but feedback from others is welcome :)

swentel’s picture

Status: Needs review » Needs work

Ok got a postgres server running myself and that didn't work, looking for other solutions.

artatac’s picture

happy to test the revised version when you have it but could you also attached the zipped patched module as I have tried in vain to get a handle on patching with no success!

swentel’s picture

Title: Custom seed? » Custom seed on postgres doesn't work
Status: Needs work » Postponed

Changing title, to be honest, my knowledge of postgres isn't that good, so for now, I'm going to mark this as postponed and try to talk with people at the next drupalcon in Paris and see if I can learn something from them :)

develcuy’s picture

Nice patch, sorry for not being subscribed ... will check and went back

swentel’s picture

Status: Postponed » Needs review

Ok, it should work now. I committed a fix on the drupal 6 branch, so the next built will have support for PostgreSQL finally :) I'm going to test it myself for a few days, also see if I didn't break MySQL support of course :)

swentel’s picture

Status: Needs review » Fixed

Actually, after some testing on both MySQL and PostgreSQL, all went fine and a new release is out!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.