News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Board Stats Possible?

Started by bobdole2281, August 24, 2013, 05:46:01 AM

Previous topic - Next topic

bobdole2281

Is it possible to get the stats from one of my boards specifically? Does smf have a function for that? And if so, where would I look to find it? Thanks in advance :)

Example:
Find the threads/posts in only General Discussion. (Or even a roundabout way to do this?)(More specifically, find posts/threads this month only)

Arantor

No function for that, you'll have to write your own query for it.

bobdole2281

Hmm, okay. How should I start. I need to get posts from all boards. => Then xplode it into categories (Board) => Then xplode it into month.

Any kind of functions for getting posts from all categories? I'm sorry for being so nosey. Where could I find the functions on this site?

Arantor

Make your mind up what you want... first you want stats for an individual board, then you want stats for everything subdivided by board... these are two very, very different things.

bobdole2281

I'm not sure what the difference is. I need a starting point to a program that can get stats forbposts in gernal discussion.

Specifically whoever posted the month each month.

Arantor

Wait... you don't understand the difference between getting stats for one board, versus getting the stats for all the boards at once?

Sounds to me like you don't have any real idea what you *do* want.

bobdole2281

#6
Quote from: Arantor on August 25, 2013, 11:32:35 AM
Wait... you don't understand the difference between getting stats for one board, versus getting the stats for all the boards at once?

Sounds to me like you don't have any real idea what you *do* want.

I just said I need stats for general discussion.


Do you think any of these are a good starting point:

$context['common_stats']

$context['common_stats']['latest_member']['link']

$context['common_stats']['total_topics']

$context['common_stats']['total_members']

$txt['posts_made']


bobdole2281

What about my own sql query. What about an inner join of  `smf_topics` and members? Would that be in the right direction?

Arantor

It would be helpful to know what stats you actually want. I'm absolutely certain you have no idea what those variables contain (and didn't look) because you'd know that $txt['posts_made'] is totally unsuitable.

So we're back to you not really knowing what you want and/or haven't thought it through (which means I don't want to waste time writing queries to help you because I'm damned if I'm doing something multiple times over)

We've established you want the stats for a board (and only one board). It would help to know what board id that has (since you *never* want to query the database looking for a board by its name for performance reasons), but more importantly what stats you actually want so that the proper query can be written.

A query, in case it wasn't abundantly clear, is essentially a question asked of the data. Asking the wrong question will get you the wrong answer.

bobdole2281

I know exactly what I want. It is all very much planned out and has been for weeks. I just have no clue how to describe it to your liking. Here is exactly what I am looking for:

Category 1 => General Discussion, Comic book movie news, & Memes
Category 2
Category 3

I want to find out the top poster of General Disucssion. I also want to find out the top poster in Comic book movie news. And also, in memes. Then as a 4th I want something a little different. I want who created the largest thread (in any board). Also, I need to exclude admins (or atleast just me) or the whole thing is pointless.

So I think I have to make a custom SQL query. Based on your replies to the variables I posted and the lack of luck of finding anything after browsing for hours.

Arantor

QuoteI just have no clue how to describe it to your liking. Here is exactly what I am looking for:

You start by assuming that I know nothing about what you're trying to do and explain it in terms that a child could understand. (This forces you to think through every aspect of it and omit nothing in explanation.)

QuoteI want to find out the top poster of General Disucssion.

So, for the board of General Discussion (which is which board id?), you want to know the most prevalent poster. Most prevalent of all time? Most prevalent of the past x days, weeks, months? Excluding admins? Excluding admins and moderators?

QuoteI also want to find out the top poster in Comic book movie news. And also, in memes.

And the same questions to all of the above.

QuoteThen as a 4th I want something a little different. I want who created the largest thread (in any board).

Even including boards that the user viewing the page might not be able to see? Hypothetical argument: in your private admin board (presuming you have one), there's a topic that covers some stuff and it ends up being the longest thread on the site. Unlikely but it does happen. Should this thread be excluded from calculations?

Do you want literally just the user who created it or a link to the thread too?

QuoteAlso, I need to exclude admins (or atleast just me) or the whole thing is pointless.

There's a huge difference, excluding all admins or just excluding you?

QuoteSo I think I have to make a custom SQL query. Based on your replies to the variables I posted and the lack of luck of finding anything after browsing for hours.

You'll need one query for each thing you want, by the looks of things, but that will depend on going through and answering every question I've asked. I'm not being a deliberate pain here - all the questions I'm asking do actually make a huge difference to the queries that need to be written and then the code that works with the data once queried (since I have the feeling I'll need to write that for you too)

Also note that what you're asking for in that last post is different to what you asked for originally - and had I written the code you originally asked for, you'd only be back saying it wasn't what you wanted, which would mean wasted time for both of us.

bobdole2281

The board IDs are:

General Discussion: 1
Comic Movie News: 3
Memes: 22

I'm not even using an admin board, so that's not a problem. Let's not worry about excluding that for now.  Also, I want to exclude admins if possible. Plan B, is just to exclude me

Arantor

I'm not being funny but I asked a lot more questions than you've answered there.

I'm sorry, I just don't have the patience for this. I don't like having to ask multiple times for the same information when it's relevant (because if it wasn't relevant I wouldn't be asking)

bobdole2281

You're right there were a lot more. My bad.

QuoteSo, for the board of General Discussion (which is which board id?), you want to know the most prevalent poster. Most prevalent of all time? Most prevalent of the past x days, weeks, months? Excluding admins? Excluding admins and moderators?
Most prevalent each month. Exluding admins. Not Moderators

QuoteDo you want literally just the user who created it or a link to the thread too?
The Link would be great, but is not neccesary

QuoteThere's a huge difference, excluding all admins or just excluding you?
All  admins

You don't have to write anything for me and I am not trying to be ignorant just to tick you off. I am just trying to find information on how to do something. It appears your the only one around here who ever answers my questions though.

I realize that their will be a different query for each section. I have been browsing my database for days and can't find out how to grab both BoardID and user.

Arantor

QuoteMost prevalent each month

What month? Current month? Previous month?

QuoteIt appears your the only one around here who ever answers my questions though.

That's because there are extremely few capable programmers around here any more :(

QuoteI have been browsing my database for days and can't find out how to grab both BoardID and user.

That's where queries come in. But I guarantee it will not be a fast query to fetch this, going through all the posts is a slow process.

bobdole2281

Quote from: Arantor on August 28, 2013, 04:19:59 PM
What month? Current month? Previous month?

Current Month. I'm going to do this every month.

QuoteThat's where queries come in. But I guarantee it will not be a fast query to fetch this, going through all the posts is a slow process.

And yes, that's what I was afraid of. I probably won't run this onload of the page then. I'm getting more and more familiar with queries every day. I need to figure out some queries I can start on and grow until I have it.

Arantor

Even when you're on the first of a month and thus only have that day's stats to consider? Or did you mean the last 30 days' worth of stats?

Both are possible, but require quite different queries.

As for 'getting started', SMF runs many many different queries to perform its tasks. In the scheme of SQL, they're very straightforward and simplistic though. You really don't need to master SQL fully to be able to use it competently. (The longest query I've ever written for MySQL/SMF was 23 lines. The longest query I've ever seen is a stored procedure a colleague of mine wrote which extended to almost 2000 lines of code.)

bobdole2281

Quote from: Arantor on August 29, 2013, 04:24:18 PM
Even when you're on the first of a month and thus only have that day's stats to consider? Or did you mean the last 30 days' worth of stats?

Both are possible, but require quite different queries.

As for 'getting started', SMF runs many many different queries to perform its tasks. In the scheme of SQL, they're very straightforward and simplistic though. You really don't need to master SQL fully to be able to use it competently. (The longest query I've ever written for MySQL/SMF was 23 lines. The longest query I've ever seen is a stored procedure a colleague of mine wrote which extended to almost 2000 lines of code.)

Wow, that would be an intense query. I want it to consider each month,Ex: June, July, August. Not the last 30 days. I will be making some other code that limits this stuff during the first of the month already. Although I guess, it's possible to include it here as well if it's not too complicated.

Arantor

It's all doable but it's extremely difficult when 1) not all the consequences have been talked about and 2) the requirements feel like they're changing every time I ask more deep questions.

bobdole2281

The requirements aren't changing, I promise you that. I am doing a poor job of communicating is all. I'll try to be more clear because I understand every little line matters.


Although I am flexible on a few parts, but that essentially means whichever is easiest. I appreciate you helping me narrow down the code like this. You've been extremely helpful.

Advertisement: