Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: Bob Perry of Web Presence Consulting on January 10, 2015, 09:26:12 PM

Title: Problem with gender tracking...
Post by: Bob Perry of Web Presence Consulting on January 10, 2015, 09:26:12 PM
Just tested with a couple accounts and it seems that the 2.1 install here is not saving the changes made to profile gender status? I do have many mods installed and seems to be relatively stable so far. But before the mods being present it seemed to work for the admin account and a female account, but now I checked it with another male account change and the stats page still shows the same number of genders, no change saved apparently... the only errors generated in the log afterward are related to google member map...

btw, what type of information is being picked up by SMF when you check the box to allow sharing of usage or whatever data with SMF during an initial install? would be nice to share error messages automatically with yall? although i realize from some sites this would be a huge amount of data to sift through and manage...
Title: Re: Problem with gender tracking...
Post by: Arantor on January 10, 2015, 09:31:14 PM
Gender is 2.1 is stored as a custom profile field, if you're trying to get it from the members table, that's not going to work.

As for the stats, once a month (in theory), SMF would contact your server, get the PHP, MySQL versions and basic stats like number of boards. Hasn't worked in ages and a year ago I was campaigning to remove them from 2.1 entirely because it hasn't worked in ages.
Title: Re: Problem with gender tracking...
Post by: Bob Perry of Web Presence Consulting on January 10, 2015, 09:40:10 PM
Quote from: Arantor on January 10, 2015, 09:31:14 PM
Gender is 2.1 is stored as a custom profile field, if you're trying to get it from the members table, that's not going to work.

Yes, I was aware that gender was removed from members db, but still trying to learn some of the new methodologies (maybe not new, just foreign to my experience?) implemented in the new version... as I understand it, the data for gender is being stored in the Themes db yes?

Title: Re: Problem with gender tracking...
Post by: Arantor on January 10, 2015, 09:43:28 PM
Yes, it is, along with all the other custom fields data has been for years.
Title: Re: Problem with gender tracking...
Post by: Illori on January 11, 2015, 06:08:27 AM
Quote from: Bob Perry on January 10, 2015, 09:40:10 PM
Quote from: Arantor on January 10, 2015, 09:31:14 PM
Gender is 2.1 is stored as a custom profile field, if you're trying to get it from the members table, that's not going to work.

Yes, I was aware that gender was removed from members db, but still trying to learn some of the new methodologies (maybe not new, just foreign to my experience?) implemented in the new version... as I understand it, the data for gender is being stored in the Themes db yes?



they are tables, not a db. the whole db is what contains all the tables that SMF requires to run.
Title: Re: Problem with gender tracking...
Post by: margarett on January 11, 2015, 04:42:56 PM
Anyway, back to your original post, this is a bug (I'll open an issue in GH in some minutes)

I have 1 user: admin --> male
QuoteGender stats: Male: 1
I add another user. As there is no gender defined, stats are the same

I define the new member's gender (as admin, editing his profile): Female
QuoteGender stats:
    Male: 1
    Female: 1
Then I change the gender to "Male"
QuoteGender stats: Male: 1
Wrong...

I change the gender to "None"
QuoteGender stats:
    Male: 1
    None: 1

Change the gender to "Male" again:
QuoteGender stats:
    Male: 1

So it fails to update the stats when the gender is set to "Male"...

edit: when there is only 1 user, it correctly updates the stats None/Male/Female: 1
edit2: https://github.com/SimpleMachines/SMF2.1/issues/2666
Title: Re: Problem with gender tracking...
Post by: Bob Perry of Web Presence Consulting on January 12, 2015, 01:04:16 AM
After a lot more cussing than I care to admit, I have this functioning perfectly+...

Replace in Sources/Stats.php and see what yall think of this...


// Let's calculate gender stats only every four minutes.
$disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
if (!in_array('gender', $disabled_fields))
{
$context['gender']['Not Set'] = comma_format($modSettings['totalMembers']);
$context['gender']['Female'] = 0;
$context['gender']['Disabled'] = 0;
$context['gender']['Male'] = 0;

$result = $smcFunc['db_query']('', '
SELECT COUNT(m.id_member) AS notset, COUNT(c.value) AS cnt, c.value AS genderhit
FROM {db_prefix}members AS m
LEFT JOIN {db_prefix}themes AS c ON c.variable = "cust_gender"
WHERE m.id_member > {int:select} AND m.id_member = c.id_member
GROUP BY c.value',
array(
'select' => 0,
)
);
while ($row = $smcFunc['db_fetch_assoc']($result))
{
$context['gender']['Not Set'] = $context['gender']['Not Set'] - $row['notset'];

// Assuming we're telling the genders in the forum...
if (!empty($row['genderhit']))
{
$context['gender'][$row['genderhit']] = $row['cnt'];
}
}
$smcFunc['db_free_result']($result);
}


enjoy...
Title: Re: Problem with gender tracking...
Post by: Bob Perry of Web Presence Consulting on January 14, 2015, 09:17:57 PM
So, as I understand it so far, this fix above would be eligible to submit at github for integration into the source? It needs some minor tweaking like putting the cache statements back in, but it functions perfect on my 2.1 site as is... I can learn to move these things over there eventually I guess, but I care little for recognition of fixing it, if someone else who wants to scrape/tweak it a little  from here and shoot it over there for consideration is more than welcome to do so if not already done, it works great is all I know right now, must sleep

Title: Re: Problem with gender tracking...
Post by: Kindred on January 15, 2015, 01:02:58 AM
the thing is.... we can not scrape it from here.   Code submitted here is not released under the usage license that you agree to when you submit code to github
Title: Re: Problem with gender tracking...
Post by: Bob Perry of Web Presence Consulting on January 15, 2015, 01:29:39 AM
Quote from: Kindred on January 15, 2015, 01:02:58 AM
the thing is.... we can not scrape it from here.   Code submitted here is not released under the usage license that you agree to when you submit code to github

Ok thanks man, I already went ahead and moved it to github as suggested but still learning how to navigate the unfamiliar format and procedures because I need to learn all that anyway with my own module under construction and progressing slowly but surely, this new SMF version hit me off guard somewhat and once I got a bit more deeply into it I saw immediately that yall have been into it amazingly over the top logically and methodically like I was accustomed to in the the IBM DB2 platform and Sequel, PHP's SQL counterpart... my enthusiasm shot through the ceiling dude, seriously this is going be be epic when completed... but anyway, so just posted it as a comment to margarett's linked issue provided, and I hope yall understand an old feller's odd mood swings at certain miscommunications and such, you'd think an old hand at non-visual text only communicating would be more tolerant, but then again... no no not going there again... this one reason I paid a small fortune for a pretty decent audio/video conference/streaming package, its not too bad but the old days of chatrooms like Yahoo was years ago are fading away fast I'm afraid, maybe the focus is just shifting to something different but you catch my drift...