Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I want to add a column for number of posts to a user view so I looked to see what was provided by User Stats to Views and I see:
User Stats: Statistic name
The unique statistic name
User Stats: Value
Statistic value
It seems like "value" is the one that I want since "name" just prints either "login_count" or "post_count" where "value" prints the actual number. But there seems to be no way to tell it which one I want and so I get one row for "login_count" and one row for "post_count". Am I missing something?
Thanks,
Michelle
Comment | File | Size | Author |
---|---|---|---|
#25 | 958022-user_stats_views_integration_d7.patch | 2.95 KB | markwk |
#18 | 958022-user_stats_views_integration.patch | 2.75 KB | lavamind |
Comments
Comment #1
Liam McDermott CreditAttribution: Liam McDermott commentedSorry for not replying to this sooner.
Badly! I didn't really implement this very well, it will be re-written at some point (though I'm concentrating on other modules at the moment).
You use the
Statistic value
as the field, then useStatistic name
as a filter, so you only get the values you want.Really there should be one Views field per-statistic, that would make a lot more sense. :)
Comment #2
MichelleHmm... So I guess there's no way to get both the login count and the number of posts on the same row. Yeah, one field per stat would be good. :) This isn't a super high priority for me but, if I happen to get to it before you do, I'll post a patch. I'll mark this fixed for now since the question is answered.
Thanks,
Michelle
Comment #4
twistedindustries CreditAttribution: twistedindustries commentedI would like to point out that I followed the instructions above and that worked great. But when I add more users via user import they are filtered out. Additionally if I remove the statistic name filter my missing users come back and are listed only once with a zero where all other users are listed twice like described originally. Any fix for this?
I was going to open a new bug report for this but it seemed easier to describe here in this issue.
Comment #5
Liam McDermott CreditAttribution: Liam McDermott commentedAh, you should have done that. This support request is only about User Stats' Views integration being really weird and whacky, your bug report is about it being broken, completely separate issues! :)
Now we're sending e-mails to Michelle on an issue she doesn't care about and I'm going to get confused about which bugs I've fixed and which I haven't.
If you wouldn't mind, please copy and paste your comment into a new issue, think up a clever title and I'll have a look at it. Thanks!
Comment #6
drupalfan2 CreditAttribution: drupalfan2 commentedStill the same problem:
How can I show user stats value in a view without a patch? Can you correct this in dev version?
Comment #7
Liam McDermott CreditAttribution: Liam McDermott commentedYou don't need a patch.
Strictly speaking, there's nothing to correct. The View integration sucks but does work, if you follow the instructions in #1. I know it's confusing, sorry. :)
Since I do intend to change this so it makes sense, instead of being really esoteric, am changing this to a bug report.
Comment #8
MichelleThat would be great. I never did get this to work without having duplicate entries and ended up using something else in that spot. I would like to be able to use this in the future, though.
Thanks,
Michelle
Comment #9
Liam McDermott CreditAttribution: Liam McDermott commentedIn that case, sorry for my previous post, I was wrong. It sucks and doesn't work! :)
Comment #10
MichelleWell, I wasn't able to get it to work. That doesn't mean it's broken; I could have been doing it wrong. :)
At any rate, a more robust field would be much appreciated once you have the time for it. I'm planning on doing the members landing page and would like to be able to make use of this integration.
Michelle
Comment #11
tim.plunkettSubscribe.
Comment #12
Drake CreditAttribution: Drake commentedI set filter User Stats: Statistic name = post_count and now I get only one field returining the value of user posts.
Comment #13
Stan.Ezersky CreditAttribution: Stan.Ezersky commentedSubscribe
Comment #14
jeffschulersubscribe
Comment #15
drupalfan2 CreditAttribution: drupalfan2 commentedIn current dev version this problem is still not solved. Why?
This is not a great thing.
How can it be solved per patch?
Comment #16
MichelleSettle down. Goodness. Remember that maintainers are volunteers. Maybe he's been busy. Maybe he doesn't know how to fix it. If it's critical to you, you could always offer a bounty or hire someone to fix it. Otherwise be patient.
Michelle
Comment #17
Liam McDermott CreditAttribution: Liam McDermott commentedSorry I haven't had time to fix this, I have started but am also busy with other work.
Unfortunately, bumping issues up to critical and being rude isn't going to make me less busy. And, as Michelle pointed out, I'm just a volunteer. :(
Comment #18
lavamind CreditAttribution: lavamind commentedHere's a patch that might help. Instead of 'name' and 'value' view fields, you can use a kind of table alias to get the data for one type of statistic, even if it's in a single table.
Please review!
Comment #19
jeffschulerThanks lavamind!
This patch is working well for me for displaying Post Count.
Comment #20
YK85 CreditAttribution: YK85 commentedsubscribing
Comment #21
Liam McDermott CreditAttribution: Liam McDermott commentedThis is similar to what I'd like to do, but for all fields. The idea is to loop through all the field names, building the Views array automatically.
The problem with the approach in this patch is it doesn't allow for dynamically added, new stats (like those gathered via our hook in user_stats_get_stats() for example).
Anyone wanting this feature OMGNOW!1!11one should use this patch though. Just don't build too many views based on it, because when I finally commit a permanent fix it may break them. :)
Comment #22
sp09 CreditAttribution: sp09 commentedDrake's solution worked perfectly for me :)
Comment #23
joachim CreditAttribution: joachim commented> The idea is to loop through all the field names, building the Views array automatically.
Wouldn't the better fix to be to normalize the database table so you have one field per value and one row per user? I'm not sure why you need the current key/value schema, as every user statistic seems to be one-to-one with a user.
Comment #24
TripleEmcoder CreditAttribution: TripleEmcoder commentedAre there actually any modules that add additional user_stats dynamically and require the schema to be the way it is?
Comment #25
markwk CreditAttribution: markwk commentedHere's the previous patch update to apply to D7 Branch. I think this is the correct way for this to function. Filtered by seems messy and unnecessary considering what most folks will be doint.
Comment #26
imoreno CreditAttribution: imoreno commentedHi,
Thank you for your patch.
While this patch does provide the number of posts field, it doesn't display anything in the view results. i suspect this patch misses something, it should display my field title at least..... but it doesn't display anything.
could you please double check that this patch was ported to D7 correctly?
BR
Itzhak
Comment #27
imoreno CreditAttribution: imoreno commentedupdate,
It does work for me, just the title is missing.
I had to reset the post counter, than run cron X times to gather all the information about the users, and now it is working as expected - it displaying the correct number of post.
THX!
Itzhak
Comment #28
drupalfan81 CreditAttribution: drupalfan81 commentedHi guys,
thanks for the awesome module, but as the original poster, I would like to get more out of the views. Has there been any progress or way to work around this?
Currently, I am able to display the user's post_count by adding that to a filter and then add the statistic value to as a field. But as mentioned above, there is no way to add another value such as login_count. I would like to have a view to display all my users in a table with columns showing their last login, their post count, their login count, etc. All in one table that I can sort on and filter.
Any idea how I can do this?
Thanks!
Comment #29
drupalfan81 CreditAttribution: drupalfan81 commentedOh btw, just to share, what I have done for now, is just expose the filter so that I can change the statistic name to change it on the fly to see the other values I want to check out. But again, I can only look at one at a time...which is just a bummer.