This module provides a field type in order to assign a "probability weight" to it.

A probability weight is a float number which indicates a weight... not a fixed weight as many other modules do, but a weight with certain degree of randomness in order to ensure desired content appears in the first places with some probability, but not always. This module allows Views module to sort content in that way.

It's very useful in marketing context, where some products are desired to be promoted, but not always, in order to avoid being annoying.

Many fields can be assigned to any entity type, so you can have not only a unique probability weight per content, but many as desired.

Project page: http://drupal.org/sandbox/grisendo/1791222
Git repo: http://git.drupal.org/sandbox/grisendo/1791222.git
Drupal version: 7.x
Module version: 7.x-1.x

Reviews of other projects (part 1):

  1. http://drupal.org/node/1784544#comment-6637674
  2. http://drupal.org/node/1820028#comment-6637376
  3. http://drupal.org/node/1678248#comment-6640988

Reviews of other projects (part 2):

  1. http://drupal.org/node/1839230#comment-6726530
  2. http://drupal.org/node/1839370#comment-6726564
  3. http://drupal.org/node/1742802#comment-6726694

Reviews of other projects (part 3):

  1. http://drupal.org/node/1839230#comment-6738138
  2. http://drupal.org/node/1839370#comment-6738180
  3. http://drupal.org/node/1841920#comment-6738264

Reviews of other projects (part 4):

  1. http://drupal.org/node/1822638#comment-6739984
  2. http://drupal.org/node/1837170#comment-6740158
  3. http://drupal.org/node/1785088#comment-6740212

Comments

developmenticon’s picture

Please include Sandbox Project, Git Repository and drupal version to get review.

zymphonies-dev’s picture

Status: Needs review » Needs work

HI

1) add git repository in summary

git clone http://git.drupal.org/sandbox/grisendo/1791222.git probabilistic_weight

2) Please fix "ventral automated code review" errors
http://ventral.org/pareview/httpgitdrupalorgsandboxgrisendo1791222git

3) Attach screenshot in this page

Thanks

grisendo’s picture

Thanks!

Sandbox project: http://drupal.org/sandbox/grisendo/1791222
Git repository: http://git.drupal.org/sandbox/grisendo/1791222.git probabilistic_weight
Drupal version: 7.x
Module version: 7.x-1.x

Ventral report is attached as a picture, and the URL was http://ventral.org/pareview/httpgitdrupalorgsandboxgrisendo1791222git

How could I fix those views-handlers related errors? I can't find other contrib modules (like Webform) with a solution for that.

zymphonies-dev’s picture

HI,

Still have few more errors. please fix.

FILE: ..._temp/test_candidate/views/probabilistic_weight_handler_sort_weight.inc
--------------------------------------------------------------------------------
FOUND 7 ERROR(S) AFFECTING 3 LINE(S)
--------------------------------------------------------------------------------
13 | ERROR | Class name must begin with a capital letter
13 | ERROR | Class name must use UpperCamel naming without underscores
15 | ERROR | Missing function doc comment
15 | ERROR | No scope modifier specified for function "query"
37 | ERROR | Missing function doc comment
37 | ERROR | Method name
| | "probabilistic_weight_handler_sort_weight::option_definition" is
| | not in lowerCamel format, it must not contain underscores
37 | ERROR | No scope modifier specified for function "option_definition"
--------------------------------------------------------------------------------

Thanks

grisendo’s picture

I would like to, but I don't know since most of them are related to Views Handlers.

37 | ERROR | Method name
| | "probabilistic_weight_handler_sort_weight::option_definition" is
| | not in lowerCamel format, it must not contain underscores

I cannot change option_definition function name since it's a overriden function with that name used in Views, and I need to override it.
How should I proceed with those kinds of errors?

Also, in all Views Handlers, and all modules I know which extends them (as I said before, i.e. Webforms), classes are named like mine: probabilistic_weight_handler_sort_weight, with underscores and lowercase.

zymphonies-dev’s picture

HI grisendo,

http://drupal.org/coding-standards
please go through this link. you will get brief idea about drupal coding standards

try, you can take your time and fix the issues.
if you are not able to fix. i will help you.

Thanks

grisendo’s picture

But I can't change "option_definition" method name to "optionDefinition" or any other, since it's a method that Views has named that way in the class I am extending (views_handler_sort), and I need to override it, it's impossible to give it another name.

zymphonies-dev’s picture

Status: Needs work » Needs review

ok cool,
we can check with other reviewers.

Reviewers,
Please review this module.

Thanks

grisendo’s picture

Thanks anyway for your help :)

grisendo’s picture

I just fixed all errors I can.

Now just 3 errors left, all of them related to Views Handlers.

Just like this: http://drupal.org/node/1546758#comment-5914906

Here is the revision link, and I also attached the new revision screenshot:
http://ventral.org/pareview/httpgitdrupalorgsandboxgrisendo1791222git

grisendo’s picture

Issue summary: View changes

Git repo, project page, version, 2 reviews

grisendo’s picture

Issue tags: +PAreview: review bonus

PAReview: review bonus

carwin’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new99.01 KB

Review

README.txt
Your README looks fine.
project page
This might be just a little pain in the butt type of thing, but as a personal preference I really like to see better project pages. At the moment your project page does give a full, valid desciption of what the module does with an example use-case. But for something like this I believe it would be helpful to at least at some screenshots of admin pages or some other sort of visual to go with the descriptions. Please take a moment to make your project page follow tips for a great project page.
Master Branch
Not using it, good man! Git branch is 7.x-1.x.
Major coding standards / best practice issues
You've already covered the ventral tests with an acceptable reason for not being able to comply. I honestly don't know of any solution to get around this so I'll just say let it slide, but I would welcome a second opinion.
I´ve attached the automated report of Coder's output as a .png file to this comment.
License
Doesn't exist, just how we like it.
access administration vs. administer site configuration
Irrelevant for this module.
files[] without classes or interfaces
class probabilistic_weight_handler_sort_weight extends views_handler_sort, your declaration of files[] in the .info file is valid.
PAReview: 3rd party code
No apparent 3rd party code exists.
Multiple Applications
Another project application exists, but it has been closed so all is well.
Already Approved
Nope not yet.
Idle Application
Not idle.
Code too short
Code length is fine.

Notes

I also took the time to manually try the module out and it works as described. I would urge you to make your project page the best it can be, but I won't hold up the release of this over something piddly like that.

Result

So, without further ado, I hereby mark this module RTBC.

klausi’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -PAreview: review bonus

Thank your for your reviews. When finishing your review comment also set the issue status either to "needs work" (you found some problems with the project) or "reviewed & tested by the community" (you found no major flaws).

manual review:

  1. please add the differences to existing modules to your project page, e.g. http://drupal.org/project/random_weight
  2. probabilistic_weight_validation(): do not use the raw $form_state['input'] where possible, always use $form_state['values'].
  3. probabilistic_weight_validation(): please add a comment to the first line in the function. What the heck is going on here?
  4. probabilistic_weight_views_api(): there is no Views 2.0 API in Drupal 7?
  5. "t('Probabilistic weight fields') . ': ' . $field['field_name'],": do not concatenate translatable strings, always use placeholders with t().
  6. probabilistic_weight_handler_sort_weight: is that order_by() MySQL specific or does that work on any database? Could you clarify that in the README.txt?

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

grisendo’s picture

Thanks all of you for your reviews!

I made some changes:

  1. please add the differences to existing modules to your project page, e.g. http://drupal.org/project/random_weight
    • Done. I didn't found any other similar, but also that one is quite different.
  2. probabilistic_weight_validation(): do not use the raw $form_state['input'] where possible, always use $form_state['values'].
    • Done. I changed the line completely.
  3. probabilistic_weight_validation(): please add a comment to the first line in the function. What the heck is going on here?
    • Done. Since I changed the linke completely (see 2.), now it is totally understandable.
  4. probabilistic_weight_views_api(): there is no Views 2.0 API in Drupal 7?
    • Changed to 3
  5. "t('Probabilistic weight fields') . ': ' . $field['field_name'],": do not concatenate translatable strings, always use placeholders with t().
    • Fixed
  6. probabilistic_weight_handler_sort_weight: is that order_by() MySQL specific or does that work on any database? Could you clarify that in the README.txt?
    • Explained. I added support for MySQL, SQLite and PostgreSQL.

I would like to create an awesome explanatory screenshot, but I am not inspired today :(

grisendo’s picture

StatusFileSize
new148.28 KB

Ok, I finally decided to make a graphic, since I didn't found any screenshot which could be not explanatory at all.
I have attached here and in the project page: http://drupal.org/sandbox/grisendo/1791222

grisendo’s picture

Status: Needs work » Needs review
grisendo’s picture

Issue summary: View changes

Third revision, PAReview: review bonus

grisendo’s picture

grisendo’s picture

Issue summary: View changes

Bonus review

stred’s picture

Pareview
Automated review outputs errors but it is a view issue (#7) .
Documentation
You should add a description under the text field explaining that the value must be lower or equal than 1 (same as error message) in probabilistic_weight_field_widget_form().
The usage of the module is not straightforward so you should add a step by step process somewhere. Can't make it working: my list is always ordered in a same way :( i give up
Read Me
Too much explanation with Random Weight. The most important (how does it work) is skipped.

I will review it deeper when I'll make it work!

ps: it works now no idea why it didn't...

klausi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus +PAreview: security

manual review:

  1. "manual review 4" is not a useful commit message. Please try to be more descriptive, see also http://drupal.org//node/52287
  2. probabilistic_weight_field_widget_form(): this is vulnerable to XSS exploits. If I enter <script>alert('XSS');</script> as help text for the field I get a nasty javascript popup on the form when editing this field. You need to sanitize user provided input in #description. Please read http://drupal.org/node/28984 again.

Security issues are blockers, otherwise this looks nearly ready. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

klausi’s picture

Issue summary: View changes

Misstyping

grisendo’s picture

Status: Needs work » Needs review
  1. "manual review 4" is not a useful commit message. Please try to be more descriptive, see also http://drupal.org//node/52287
    • Sorry, I can't change previous comments I think... but this last, and the new ones will follow the rules :)
  2. probabilistic_weight_field_widget_form(): this is vulnerable to XSS exploits. If I enter
    alert('XSS');

    as help text for the field I get a nasty javascript popup on the form when editing this field. You need to sanitize user provided input in #description. Please read http://drupal.org/node/28984 again.

    • Extreme facepalm... Fixed, if filter_xss_admin is enough.

Added 3 new reviews, and Review Bonus tag.

klausi’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus +PAreview: security

Please don't remove the security tag, we keep that for statistics and to show examples of security problems.

Looks RTBC now. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

klausi’s picture

Issue summary: View changes

Three new reviews for Bonus Review

klausi’s picture

Status: Reviewed & tested by the community » Fixed

no objections for more than a week, so ...

Thanks for your contribution, grisendo!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

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

Anonymous’s picture

Issue summary: View changes

Three new revisions, bonus review tag