Hi,

I think it would be helpful to have a "clear all recorded statistics" button. For example, this would be useful for when a site transitions from being a private "development" site to being a public "live" site.

Files: 
CommentFileSizeAuthor
#25 54798.reset-statistics.25.patch2.66 KBnaxoc
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch 54798.reset-statistics.25.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#22 54798.reset-statistics.022.patch3.23 KBkarschsp
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 54798.reset-statistics.022.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#21 54798.reset-statistics.021.patch3.58 KBkarschsp
PASSED: [[SimpleTest]]: [MySQL] 34,009 pass(es).
[ View ]
#17 54798-clear-statistics.patch4.79 KBTR
FAILED: [[SimpleTest]]: [MySQL] Failed to run tests: failed during invocation of run-tests.sh.
[ View ]
#11 jsomers_54798_5-D7.patch3.78 KBj.somers
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#9 jsomers_54798_4-D7.patch3.86 KBj.somers
Passed: 11804 passes, 0 fails, 0 exceptions
[ View ]
#6 jsomers_54798_3.patch3.89 KBj.somers
Failed: Failed to apply patch.
[ View ]
#5 jsomers_54798_2.patch1.32 KBj.somers
Failed: Failed to apply patch.
[ View ]
#3 jsomers_54798_1.patch1.29 KBj.somers
Failed: Failed to apply patch.
[ View ]

Comments

Version:x.y.z» 7.x-dev
Priority:Normal» Minor

Bump.

Subscribing. I agree, this is a pretty basic need and common use case. Thanks, Andrew.

Status:Active» Needs review
StatusFileSize
new1.29 KB
Failed: Failed to apply patch.
[ View ]

Attached is a small patch which adds a button to the statistics administration page similar to the "Clear cache" button on the performance administration page. The description and title information could possibly be described better.

Status:Needs review» Needs work

I'd include the node_counter table as well since it is a part of the statistics.module.

StatusFileSize
new1.32 KB
Failed: Failed to apply patch.
[ View ]

I added it in the attached patch, but note that the node_counter table is not created by the statistics module.

Status:Needs work» Needs review
StatusFileSize
new3.89 KB
Failed: Failed to apply patch.
[ View ]

Discard the previous patch, I added a test case in the attached one.

Status:Needs review» Needs work

The last submitted patch failed testing.

Assigned:Unassigned» j.somers

Don't really see why applying the patch would have failed but after #463064: 'content' cannot be used as a $form element and breaks any page which uses it, such as admin/settings/statistics has been resolved I shall create a new version.

Assigned:j.somers» Unassigned
Status:Needs work» Needs review
StatusFileSize
new3.86 KB
Passed: 11804 passes, 0 fails, 0 exceptions
[ View ]

Re-roll.

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

+  /**
+   * Enable required modules and create users with specific permissions.
+   */

This isn't need for setUp().

The delete from table should use db_truncate()->execute().

Status:Needs work» Needs review
StatusFileSize
new3.78 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

Updated the patch to make sure it works on the latest D7 version and applied remarks in comment #10.

#11: jsomers_54798_5-D7.patch queued for re-testing.

The patch from #11 works well for me.

I applied it to the CVS HEAD and the patch applied correctly. The button was indeed added to the statistics admin area and clicking reset had the desired behavior of resetting the site hit statistics.

Status:Needs review» Reviewed & tested by the community

Marking as RTBC because of comment #13.

Version:7.x-dev» 8.x-dev

Sorry, we're past feature freeze (and string freeze) for D7; new features go in the next release of Drupal.

Status:Reviewed & tested by the community» Needs review
Issue tags:+needs backport to D7

It's been a year and a half since the patch, so I re-rolled it against the D8 head. The only changes I made from the patch in #11 were to remove trailing whitespace, add doxygen comments, and modify some doxygen comments to bring up to standards.

I tested this patch in Drupal 8.x and it works as advertised.

This issue has been open for 5 years! I'm reluctantly changing the status to needs review to force the testbot to test the patch, but I'd like to think this is RTBC. Maybe someone else can do a quick review and we can finally get this closed.

StatusFileSize
new4.79 KB
FAILED: [[SimpleTest]]: [MySQL] Failed to run tests: failed during invocation of run-tests.sh.
[ View ]

It would help if I actually attached the patch ...

Status:Needs review» Needs work
Issue tags:-needs backport to D7

The last submitted patch, 54798-clear-statistics.patch, failed testing.

Status:Needs work» Needs review

#17: 54798-clear-statistics.patch queued for re-testing.

Previous test failure seems like it was a testbot problem: "PHP Fatal error: Class 'DrupalWebTestCase' not found"

Status:Needs review» Needs work
Issue tags:+needs backport to D7

The last submitted patch, 54798-clear-statistics.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new3.58 KB
PASSED: [[SimpleTest]]: [MySQL] 34,009 pass(es).
[ View ]

Here's a re-roll for 8.x.

StatusFileSize
new3.23 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 54798.reset-statistics.022.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Fixing whitespace issues.

Issue tags:-needs backport to D7

#22: 54798.reset-statistics.022.patch queued for re-testing.

Status:Needs review» Needs work
Issue tags:+needs backport to D7

The last submitted patch, 54798.reset-statistics.022.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new2.66 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch 54798.reset-statistics.25.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Reroll.

I did some cleanup in the test - mainly removing the t() around the text in assertions.

I don't think removing the t() is appropriate until #500866: [META] remove t() from assert message is committed.

@TR - t() should not be added to new tests anymore. See http://drupal.org/node/265828 at the top.

The revision history of the documentation you cite at http://drupal.org/node/265828 says that this documentation was changed because of what is being discussed in #500866: [META] remove t() from assert message. So again, I think it was premature and inappropriate to change the documentation before the community has finished deciding the issue. #500866: [META] remove t() from assert message has been open a long time - I don't think that subverting the community process by making changes in anticipation of the expected outcome of #500866: [META] remove t() from assert message is something that we should be doing.

Current documentation says don't use t(): http://drupal.org/simpletest-tutorial-drupal7#t

Reference found here: http://drupal.org/node/500866#comment-5654154

25: 54798.reset-statistics.25.patch queued for re-testing.

Status:Needs review» Needs work

The last submitted patch, 25: 54798.reset-statistics.25.patch, failed testing.