I created a Drush extension that I've been using day-to-day and would like to share. This extension allows you to quickly see which authenticated users last accessed and logged into your site. I wrote it to give me more information for planning the best time to carry out scheduled maintenance on on a multisite configuration that has active users spanning several timezones.
It's my first real code contribution to the community so it's just a sandbox project. I don't know whether to go through with applying for full project access or not - the functionality it provides might not be suitable as a standalone extension and maybe it would be better adding it to Drush or Drush Extras. Also I think the code review process seems to be more geared to working with modules and themes, and large-ish ones at that.
Feel free to get the code from http://drupal.org/sandbox/mgtsol/1927212 and make sure to grab branch 7.x-1.0-dev or 7.x-1.0-alpha1
If anyone has any feedback/comments/suggestions on the project or the code, I'd really appreciate it. As I said it's my first real code contribution so any hints and tips that will allow me contribute effectively in the future will be very helpful.
Comments
Comment #1
greg.1.anderson commentedLooks pretty good. You could publish this as a separate module if you want; I'd also take it in drush_extras if you'd prefer to go that route.
--exclude-uid1 looks a little awkward; maybe --no-admin could exclude uid1 + all users who have the administrator role?
You should probably use '0' instead of 'NULL' for the default value in
(drush_get_option('mins', NULL), etc.; the code will run the same, but the intention is to use 'mins' as an integer, so the default should be an integer for clarity.You might also consider supporting the Drush 6 output formats feature. I'd direct you to
drush topic docs-output-formats, but you would run afoul of #1366098: Automatically download Symfony YAML component if you did that. :(Comment #2
markgifford commentedYou're right about --exclude-uid1. At the very least I think I'll rename that to --no-uid1. And your suggestion about --no-admin has given me another idea about expanding it to make use of users' roles in the query that gets built and the table that gets output. It would actually be useful for me personally to optionally filter by role when using this every day. The only user on my sites with "administrator" role is uid1, but we do have another custom role that I'd like to filter by. Ultimately I'd like to be able to pass --no-role="[role1],[role2]" and/or --role="[role3],[role4]" so that could be fun to try and get working.
Good point re: using an integer instead of NULL. Just the kind of thing I'd never have picked up. I'll investigate Drush 6 output formats -- I've not yet dug very deeply into the differences between the Drush's major versions -- and keep an eye on that issue you linked to.
I think I'll carry on developing it over the next few days and then when I see how that pans out I'll look into putting into Drupal Extras. Thanks for taking the time to comment.
Comment #3
greg.1.anderson commentedThis issue was marked
closed (won't fix)because Drush has moved to Github.If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to
closed (duplicate).Please ask support questions on Drupal Answers.