Skip to content

Commit

Permalink
Merge pull request kestasjk#694 from Squigs44/grIntegration
Browse files Browse the repository at this point in the history
Change date formatting for ease of use later
  • Loading branch information
jmo1121109 authored Jun 27, 2020
2 parents 1b3a97e + fdad202 commit 70c022d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions ghostratings/calculations.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,31 +135,31 @@ public function processGR()
//First we need to grab everyones GR for this category to use in the calculations
$userGR = array();
$peakGR = array();
$monthYear = array();
$yearMonth = array();
$grSum = 0;
$first = True;
$date = date('my',$this->time);
$date = date('Ym',$this->time);
foreach($this->SCcounts as $userID=>$scs)
{
$rating = $this->start;
$peakRating = $rating;
$userDate = $date;
$sqlCount = "SELECT COUNT(1) FROM wD_GhostRatings WHERE categoryID=".$categoryID." AND userID=".$userID;
$sql = "SELECT rating, peakRating, monthYear FROM wD_GhostRatings WHERE categoryID=".$categoryID." AND userID=".$userID;
$sql = "SELECT rating, peakRating, yearMonth FROM wD_GhostRatings WHERE categoryID=".$categoryID." AND userID=".$userID;
$inDB = 1;
list($inDB) = $DB->sql_row($sqlCount);
if ($inDB < 1)
{
$DB->sql_put("INSERT INTO wD_GhostRatings(userID, categoryID, rating, peakrating, monthYear) VALUES(".$userID.", ".$categoryID.", ".$rating.", ".$peakRating.", ".$date.")");
$DB->sql_put("INSERT INTO wD_GhostRatingsHistory(userID, categoryID, monthYear, rating) VALUES(".$userID.", ".$categoryID.", ".$date.", ".$rating.")");
$DB->sql_put("INSERT INTO wD_GhostRatings(userID, categoryID, rating, peakrating, yearMonth) VALUES(".$userID.", ".$categoryID.", ".$rating.", ".$peakRating.", ".$date.")");
$DB->sql_put("INSERT INTO wD_GhostRatingsHistory(userID, categoryID, yearMonth, rating) VALUES(".$userID.", ".$categoryID.", ".$date.", ".$rating.")");
}
else
{
list($rating, $peakRating, $userDate) = $DB->sql_row($sql);
}
$userGR[$userID] = $rating;
$peakGR[$userID] = $peakRating;
$monthYear[$userID] = $userDate;
$yearMonth[$userID] = $userDate;
$grSum += $rating;
}
$grAdjustment = array();
Expand Down Expand Up @@ -338,14 +338,14 @@ public function processGR()
{
$sqlUpdate = $sqlUpdate . ", peakRating=".$newRating;
}
if ($date <> $monthYear[$userID])
if ($date <> $yearMonth[$userID])
{
$sqlUpdate = $sqlUpdate. ", monthYear=".$date;
$DB->sql_put("INSERT INTO wD_GhostRatingsHistory(userID, categoryID, monthYear, rating) VALUES(".$userID.", ".$categoryID.", ".$date.", ".$newRating.")");
$sqlUpdate = $sqlUpdate. ", yearMonth=".$date;
$DB->sql_put("INSERT INTO wD_GhostRatingsHistory(userID, categoryID, yearMonth, rating) VALUES(".$userID.", ".$categoryID.", ".$date.", ".$newRating.")");
}
else
{
$DB->sql_put("UPDATE wD_GhostRatingsHistory SET rating=".$newRating." WHERE userID=".$userID." AND categoryID=".$categoryID." AND monthYear=".$date." LIMIT 1");
$DB->sql_put("UPDATE wD_GhostRatingsHistory SET rating=".$newRating." WHERE userID=".$userID." AND categoryID=".$categoryID." AND yearMonth=".$date." LIMIT 1");
}
$sqlUpdate = $sqlUpdate . " WHERE categoryID=".$categoryID." AND userID=".$userID." LIMIT 1";
$DB->sql_put($sqlUpdate);
Expand Down
8 changes: 4 additions & 4 deletions install/1.65-1.66/update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ CREATE TABLE `wD_GhostRatings` (
`categoryID` mediumint(8) unsigned NOT NULL,
`rating` FLOAT,
`peakRating` FLOAT,
`monthYear` smallint(4) unsigned NOT NULL,
`yearMonth` mediumint(6) unsigned NOT NULL,
INDEX ( `userID` ),
INDEX ( `categoryID` ),
INDEX ( `monthYear` )
INDEX ( `yearMonth` )
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `wD_GhostRatingsHistory` (
`userID` mediumint(8) unsigned NOT NULL,
`categoryID` mediumint(8) unsigned NOT NULL,
`monthYear` smallint(4) unsigned NOT NULL,
`yearMonth` mediumint(6) unsigned NOT NULL,
`rating` FLOAT,
INDEX ( `userID` ),
INDEX ( `categoryID` ),
INDEX ( `monthYear` )
INDEX ( `yearMonth` )
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `wD_GhostRatingsBackup` (
Expand Down
8 changes: 4 additions & 4 deletions install/FullInstall/fullInstall.sql
Original file line number Diff line number Diff line change
Expand Up @@ -944,20 +944,20 @@ CREATE TABLE `wD_GhostRatings` (
`categoryID` mediumint(8) unsigned NOT NULL,
`rating` FLOAT,
`peakRating` FLOAT,
`monthYear` smallint(4) unsigned NOT NULL,
`yearMonth` mediumint(6) unsigned NOT NULL,
INDEX ( `userID` ),
INDEX ( `categoryID` ),
INDEX ( `monthYear` )
INDEX ( `yearMonth` )
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `wD_GhostRatingsHistory` (
`userID` mediumint(8) unsigned NOT NULL,
`categoryID` mediumint(8) unsigned NOT NULL,
`monthYear` smallint(4) unsigned NOT NULL,
`yearMonth` mediumint(6) unsigned NOT NULL,
`rating` FLOAT,
INDEX ( `userID` ),
INDEX ( `categoryID` ),
INDEX ( `monthYear` )
INDEX ( `yearMonth` )
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `wD_GhostRatingsBackup` (
Expand Down

0 comments on commit 70c022d

Please sign in to comment.