Changeset 830 for trunk


Ignore:
Timestamp:
Aug 24, 2015, 6:55:04 PM (9 years ago)
Author:
chronos
Message:
  • Modified: Single SQL query per translation table for user translation xp calculation.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Translation/UserLevel.php

    r827 r830  
    2121function GetXPFromTranslation($UserId)
    2222{
    23   global $System, $TranslationTree, $xp_from_word, $from_diakrit;
     23  global $System, $TranslationTree, $xp_from_word, $from_diakrit, $Config;
    2424
    2525  $xp = 0;
     
    2929    {
    3030      $GroupBy = 'GROUP BY ';
     31      $TakeColumns = '';
    3132      foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem)
    3233      {
    33         $GroupBy .= '`'.$TextItem['Column'].'`, ';
     34        $GroupBy .= '`T`.`'.$TextItem['Column'].'`, ';
     35        $TakeColumns .= ', `T2`.`'.$TextItem['Column'].'` AS `'.$TextItem['Column'].'_Take`';
    3436      }
    3537      $GroupBy = substr($GroupBy, 0, -2);
    3638
    37       $IDtran = $System->Database->query('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE '.
    38         '(`User` = '.$UserId.') AND (`Complete` = 1) AND (`Take` IS NOT NULL) '.$GroupBy);
     39      $IDtran = $System->Database->query('SELECT *, `T2`.`Language` AS `Language_Take`'.$TakeColumns.' FROM `'.$Group['TablePrefix'].'` AS `T` '.
     40        'LEFT JOIN `'.$Group['TablePrefix'].'` AS `T2` ON `T2`.`ID` = `T`.`Take` '.
     41        'WHERE (`T`.`User` = '.$UserId.') AND (`T`.`Complete` = 1) AND (`T`.`Take` IS NOT NULL) '.$GroupBy);
    3942      while($Line = $IDtran->fetch_array())
    4043      {
    41         $DbResult = $System->Database->query('SELECT * FROM `'.$Group['TablePrefix'].'` WHERE `ID` = '.$Line['Take']);
    42         $LineComparison = $DbResult->fetch_assoc();
    4344        $xp_translation = 0;
    4445        $translated = true;
    4546        foreach($TranslationTree[$Group['Id']]['Items'] as $Index => $TextItem)
    4647        {
    47           if(($Line[$TextItem['Column']] <> $LineComparison[$TextItem['Column']]) and
    48             (strlen($Line[$TextItem['Column']]) > (strlen($LineComparison[$TextItem['Column']]) * 0.5)))
     48          if(($Line[$TextItem['Column']] <> $Line[$TextItem['Column'].'_Take']) and
     49            (strlen($Line[$TextItem['Column']]) > (strlen($Line[$TextItem['Column'].'_Take']) * 0.5)))
    4950          {
    5051            $TextArr = explode(' ', $Line[$TextItem['Column']]);
     
    5758          } else
    5859          {
    59             if (($Line[$TextItem['Column']] == $LineComparison[$TextItem['Column']]) and
    60               ('0' == $LineComparison['Language']) and ($LineComparison[$TextItem['Column']] <> '') and
     60            if (($Line[$TextItem['Column']] == $Line[$TextItem['Column'].'_Take']) and
     61              ($Config['OriginalLanguage'] == $Line['Language_Take']) and ($Line[$TextItem['Column'].'_Take'] <> '') and
    6162              ($TextItem['Column'] <> 'ShortCut')) $translated = false;
    6263          }
  • trunk/includes/Version.php

    r829 r830  
    66// and system will need database update.
    77
    8 $Revision = 829; // Subversion revision
     8$Revision = 830; // Subversion revision
    99$DatabaseRevision = 811; // Database structure revision
    10 $ReleaseTime = '2015-03-25';
     10$ReleaseTime = '2015-08-24';
Note: See TracChangeset for help on using the changeset viewer.