Overview

(from Sandbox page: http://drupal.org/sandbox/ethanw/1369794)

The Counter API module provides a generic infrastructure for the creation of event counters that can be incremented, managed and displayed as needed by other modules. Use cases for this module include "action" counters which can display the number of users who have participated in a given site action and donation progress bars that show "amount to goal".

On it's own the Counter API module provides an administration interface for the creation and management of individual counters, as well as tools for the manual setting and incrementing of counter values. This package also includes a simple module allowing for the display of counter values within blocks and is now integrated with the Actions API.

Comparison with Existing Modules

While there are other modules that deal with "counters", they are almost universally with very specific counter types, usually dealing with site statistics.

Compared to the modules listed below, this module is aimed at supporting a wide range of use cases in which information that may grow over time is presented to site visitors. The use cases originally scoped were specifically those related to user engagement: SMS messages sent, petitions signed, etc., though the module could be used for a wide range of purposes.

  • Counter: provides a block for presentation of site visit statistics, IP, etc. Not intended to support ad hoc counters like Counter API would.
  • View Counter: is a more general tool than Counter, but intended for analysis of Node types and other entities integrated with Views, also not general purpose counter and does not support simple counter display for users of the sort that Counter API does.
  • Stuff Counter: intended as a more general framework, but like View Counter is views based, and was never committed to the repo.

Roadmap

The current development priorities for this module are:

  • Porting to Drupal 7
  • Creation of additional display types for Counter Block, including "amount to goal" progress bar.

Reviews of Other Projects

CommentFileSizeAuthor
#17 drupalcs-result.txt2.79 KBklausi

Comments

patrickd’s picture

You got some coding standart issues (See http://ventral.org/pareview/httpgitdrupalorgsandboxethanw1369794git, you can use this site to re-test your self)

If you got any questions on that please ask!

drupalnetworks’s picture

Status: Needs review » Needs work

Review of the 6.x-1.x branch:

Drupal Code Sniffer has found some code style issues (please check the Drupal coding standards):

FILE: ...al-7-pareview/sites/all/modules/pareview_temp/test_candidate/README.txt
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
22 | WARNING | Line exceeds 80 characters; contains 87 characters
--------------------------------------------------------------------------------

FILE: ...test_candidate/plugins/export_ui/counter_api_ctools_export_ui.class.php
--------------------------------------------------------------------------------
FOUND 34 ERROR(S) AND 1 WARNING(S) AFFECTING 28 LINE(S)
--------------------------------------------------------------------------------
3 | ERROR | The second line in the file doc comment must be " * @file"
9 | ERROR | Class name must begin with a capital letter
9 | ERROR | Class name must use UpperCamel naming without underscores
13 | ERROR | Method name "counter_api_ctools_export_ui::set_value_page" is
| | not in lowerCamel format, it must not contain underscores
30 | ERROR | Space found before comma in function call
43 | ERROR | Missing comment for param "$form" at position 1
44 | ERROR | Last parameter comment requires a blank newline after it
44 | ERROR | Missing comment for param "$form_state" at position 2
49 | ERROR | Method name "counter_api_ctools_export_ui::set_value_form" is
| | not in lowerCamel format, it must not contain underscores
67 | ERROR | Missing comment for param "$form" at position 1
68 | ERROR | Last parameter comment requires a blank newline after it
68 | ERROR | Missing comment for param "$form_state" at position 2
70 | ERROR | Missing comment for @return statement
72 | ERROR | Method name
| | "counter_api_ctools_export_ui::set_value_form_validate" is not
| | in lowerCamel format, it must not contain underscores
81 | ERROR | Missing comment for param "$form" at position 1
82 | ERROR | Last parameter comment requires a blank newline after it
82 | ERROR | Missing comment for param "$form_state" at position 2
84 | ERROR | Missing comment for @return statement
86 | ERROR | Method name
| | "counter_api_ctools_export_ui::set_value_form_submit" is not
| | in lowerCamel format, it must not contain underscores
96 | ERROR | Method name
| | "counter_api_ctools_export_ui::increment_value_page" is not in
| | lowerCamel format, it must not contain underscores
126 | ERROR | Missing comment for param "$form" at position 1
127 | ERROR | Last parameter comment requires a blank newline after it
127 | ERROR | Missing comment for param "$form_state" at position 2
132 | ERROR | Method name
| | "counter_api_ctools_export_ui::increment_value_form" is not in
| | lowerCamel format, it must not contain underscores
139 | WARNING | A comma should follow the last multiline array item. Found:
| | "The value of the counter as of this page being displayed.
| | Note this might change between the time this page is generated
| | and when you submit this form."
157 | ERROR | Missing comment for param "$form" at position 1
158 | ERROR | Last parameter comment requires a blank newline after it
158 | ERROR | Missing comment for param "$form_state" at position 2
160 | ERROR | Missing comment for @return statement
162 | ERROR | Method name
| | "counter_api_ctools_export_ui::increment_value_form_validate"
| | is not in lowerCamel format, it must not contain underscores
168 | ERROR | Missing comment for param "$form" at position 1
169 | ERROR | Last parameter comment requires a blank newline after it
169 | ERROR | Missing comment for param "$form_state" at position 2
171 | ERROR | Missing comment for @return statement
173 | ERROR | Method name
| | "counter_api_ctools_export_ui::increment_value_form_submit" is
| | not in lowerCamel format, it must not contain underscores
--------------------------------------------------------------------------------

FILE: ..._temp/test_candidate/plugins/export_ui/counter_api_ctools_export_ui.inc
--------------------------------------------------------------------------------
FOUND 4 ERROR(S) AFFECTING 3 LINE(S)
--------------------------------------------------------------------------------
2 | ERROR | Missing file doc comment
49 | ERROR | Inline comments must start with a capital letter
49 | ERROR | Inline comments must end in full-stops, exclamation marks, or
| | question marks
99 | ERROR | Files must end in a single new line character
--------------------------------------------------------------------------------

This automated report was generated with PAReview.sh, your friendly project application review script. Go and review some other project applications, so we can get back to yours sooner.
Source: http://ventral.org/pareview - PAReview.sh online service

ethanw’s picture

Status: Needs work » Needs review

Thanks patrickd and drupalnetworks!

We'd run through Coder, but not DrupalCS.

Fixes for all standards issues identified by DrupalCS have been uploaded, with the exception of issues related to the CTools Export UI.

The Export UI API uses underscore notation for its classes and methods, not Camel Case. See ctools_export_ui.class.php and example reference implementation for API requirements/standards.

Coding standards issues that result from the Export UI specification are:

FILE: ...test_candidate/plugins/export_ui/counter_api_ctools_export_ui.class.php
--------------------------------------------------------------------------------
FOUND 10 ERROR(S) AFFECTING 9 LINE(S)
--------------------------------------------------------------------------------
10 | ERROR | Class name must begin with a capital letter
10 | ERROR | Class name must use UpperCamel naming without underscores
14 | ERROR | Method name "counter_api_ctools_export_ui::set_value_page" is
| | not in lowerCamel format, it must not contain underscores
53 | ERROR | Method name "counter_api_ctools_export_ui::set_value_form" is
| | not in lowerCamel format, it must not contain underscores
80 | ERROR | Method name
| | "counter_api_ctools_export_ui::set_value_form_validate" is not
| | in lowerCamel format, it must not contain underscores
98 | ERROR | Method name
| | "counter_api_ctools_export_ui::set_value_form_submit" is not in
| | lowerCamel format, it must not contain underscores
108 | ERROR | Method name "counter_api_ctools_export_ui::increment_value_page"
| | is not in lowerCamel format, it must not contain underscores
147 | ERROR | Method name "counter_api_ctools_export_ui::increment_value_form"
| | is not in lowerCamel format, it must not contain underscores
181 | ERROR | Method name
| | "counter_api_ctools_export_ui::increment_value_form_validate" is
| | not in lowerCamel format, it must not contain underscores
196 | ERROR | Method name
| | "counter_api_ctools_export_ui::increment_value_form_submit" is
| | not in lowerCamel format, it must not contain underscores

Given that these issues result from an established API specification, does this bring the module into sufficient coding standards compliance?

Is there a process for resolving conflicts between established API standards and coding standards, such as this one? Note that if this fix is not sufficient, the Views module is also not in sufficient compliance, due to views_ui.class.php.

ericduran’s picture

@ethanwl, you can feel free to ingore the coding standard regarding exported code.

We have some open issues with ctools and also some in drupalcs in regards to best solve this problem.

ethanw’s picture

Thanks @ericduran.

For reference, related tickets appear to be: http://drupal.org/node/1366844 and http://drupal.org/node/1339084.

Robertas’s picture

Status: Needs review » Needs work

counter_api.module:69 and similar places:
watchdog('action', 'Incremented/decremented counter %counter_name', array('%counter_name' => check_plain($context['counter_name'])));

Here call to check_plain() is redudant, since using '%' placeholders is already checking for plain text.

ethanw’s picture

Status: Needs work » Needs review

Thanks Robertas.

I've removed both check_plain's in watchdog calls.

greggles’s picture

Thanks for comparing to several modules.

How does this compare to http://drupal.org/project/sampler ?

ethanw’s picture

Thanks for highlighting that module I missed, @greggles.

I have not used Sampler API to date, but reviewing the project description and code I think the primary difference is that Sampler API is intended to poll a data source periodically and store samples of scalar values at each poll time (not necessarily the current value). Counter API, on the other hand, tracks incremental changes to a value, and is meant to be called directly on each update, not via a periodic call.

I can see these modules having quite a happy life together, actually, with a Sampler periodically checking the value of a Counter to provide support for historical data display and such. I also think that some of the data storage abstractions used in (the much more mature) Sampler API could be good guidelines for Counter API as it develops.

That said, I do think they are different enough so that this module does not duplicate Sampler's functionality. Sampler API is structured very elegantly to support it's specific use case, and while it might be modified to work for a counter as well, I think this would involve extra complexity for users and likely not serve Sampler API's architectural approach much. Similarly, there will likely be a number of "increment-specific" optimizations and features to be integrated into the Counter API which would not fit for Sampler.

greggles’s picture

Agreed there's not much duplication there - I ask mostly because others will ask and it's important to have a good answer for them. It would be great if you could add a wiki comparing all these at http://groups.drupal.org/similar-module-review and then link to that from your project page.

ethanw’s picture

I've created a wiki page comparing a few other data collection modules here: http://groups.drupal.org/node/198813.

ethanw’s picture

Priority: Normal » Major

Raising priority to Major since it's been a bit over two weeks awaiting a reviewer response, following process in http://drupal.org/node/539608.

Thanks!

ethanw’s picture

Raising priority to Major since it's been a bit over two weeks awaiting a reviewer response, following process in http://drupal.org/node/539608.

Thanks!

rade’s picture

Status: Needs review » Needs work

manual review of 6.x-1.x branch:

  • counter_api_ctools_export_ui.class.php line 31 and 125, unexpected period at end of line.
  • counter_api.install, line 96 ''columns' => array('pid' => 'pid'),': There is no field named 'pid' in the specified table, these should probably be 'cid'?
  • admin/settings/actions: In the dropdown list the last item (generated by your module) shows up as "..." and trying to select it and press "Create" returns an error.
  • counter_api_block.admin.inc: You have some empty functions at the end of the file, please remove them if not used.

Get a review bonus and we'll get back to you sooner.

rade’s picture

Issue summary: View changes

Fixed typo.

ethanw’s picture

Priority: Major » Normal
Status: Needs work » Needs review

Thanks @Rade.

I've addressed all the issues you listed in the 6.x-1.x branch:

Note that I've also included links to 3 past review comments. I will try to pluck another project from the current Needs Review queue before marking this issue as high priority. Hope that helps!

ethanw’s picture

Issue summary: View changes

Added links to past reviews

ethanw’s picture

Issue tags: +PAreview: review bonus

Provided links to 3 projects reviewed as application for PAReview bonus. Note that 2 of these are currently open review issues. While I understand that this is contrary to the recommendations in the review guidelines, the older of these two is not especially active at the moment, and I do not anticipate either to require so much attention that they would make it difficult for me to review them in parallel.

ethanw’s picture

Issue summary: View changes

Added new review comment to "Reviews of Other Projects" list.

ethanw’s picture

Issue summary: View changes

Added other sandbox projects awaiting full project approval status.

ethanw’s picture

Issue summary: View changes

Fixed typo.

klausi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus
StatusFileSize
new2.79 KB

Review of the 6.x-1.x branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Get a review bonus and we will come back to your application sooner.

You can ignore the coding standard issues for class/method names.

manual review:

  • "@param mixed $object": is this variable really mixet, or is it "object"? If it is mixed you should describe what types it can be.
  • "$insert_sql = "INSERT INTO {counter_api_ticks} (cid, delta) values (%d, %d)";": you should use drupal_write_record() here.
  • "TODO: Enter file description here.": Shouldn't be too hard to fill in a sentence, right?
  • counter_api_block_theme(): you don't need to document the parameters of a hook implementation, see http://drupal.org/node/1354#hookimpl
  • counter_api_block_get_config(): white space errors after "=>" and "=" in that function.
  • "$block_name = "Counter: ";": all user facing text should run through t() for translation. And don't forget to use a placeholder.
  • _counter_api_block_block_save(): "Returns the 'save' $op info for hook_block().": this function does not return anything?
  • _counter_api_block_block_save(): "// Update block information in the block table.": comment is wrong, this is not what the code does.
  • _counter_api_block_format_title(): admin_title and 'counter_name' are not sanitized, right? This can lead to XSS vulnerabilities.
  • "$block['subject'] = $counter->description;" same here, XSS vulnerable I guess.

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

klausi’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

klausi’s picture

Issue summary: View changes

Removed pending projects section: major one, Backbone, now has a few potential routes to full project-hood.

avpaderno’s picture

Title: Counter API » [D7] Counter API