Skip to content

Commit

Permalink
*8706* Use timestamp to make register unique and delete by that
Browse files Browse the repository at this point in the history
  • Loading branch information
beghelli committed Apr 16, 2014
1 parent 6c08348 commit fb069c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions plugins/generic/usageStats/UsageStatsLoader.inc.php
Expand Up @@ -230,12 +230,12 @@ function processFile($filePath, &$errorMsg) {
if ($secondsBetweenRequests < $timeFilter) {
// We have to store the last access,
// so we delete the most recent one.
$statsDao->deleteRecord($assocType, $assocId, $loadId);
$statsDao->deleteRecord($assocType, $assocId, $lastInsertedEntries[$entryHash], $loadId);
}
}

$lastInsertedEntries[$entryHash] = $entryData['date'];
$statsDao->insert($assocType, $assocId, $day, $countryCode, $region, $cityName, $type, $loadId);
$statsDao->insert($assocType, $assocId, $day, $entryData['date'], $countryCode, $region, $cityName, $type, $loadId);
}

fclose($fhandle);
Expand Down
17 changes: 9 additions & 8 deletions plugins/generic/usageStats/UsageStatsTemporaryRecordDAO.inc.php
Expand Up @@ -37,23 +37,25 @@ function UsageStatsTemporaryRecordDAO() {
* @param $assocType int
* @param $assocId int
* @param $day string
* @param $time int
* @param $countryCode string
* @param $region int
* @param $cityName string
* @param $fileType int
* @param $loadId string
* @return boolean
*/
function insert($assocType, $assocId, $day, $countryCode, $region, $cityName, $fileType, $loadId) {
function insert($assocType, $assocId, $day, $time, $countryCode, $region, $cityName, $fileType, $loadId) {
$this->update(
'INSERT INTO usage_stats_temporary_records
(assoc_type, assoc_id, day, country_id, region, city, file_type, load_id)
(assoc_type, assoc_id, day, entry_time, country_id, region, city, file_type, load_id)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?)',
(?, ?, ?, ?, ?, ?, ?, ?, ?)',
array(
(int) $assocType,
(int) $assocId,
$day,
(int) $time,
$countryCode,
(int) $region,
$cityName,
Expand Down Expand Up @@ -102,15 +104,14 @@ function deleteByLoadId($loadId) {
* the most recent day value.
* @param $assocType int
* @param $assocId int
* @param $time int
* @param $loadId string
* @return boolean
*/
function deleteRecord($assocType, $assocId, $loadId) {
function deleteRecord($assocType, $assocId, $time, $loadId) {
return $this->update('DELETE from usage_stats_temporary_records
WHERE assoc_type = ? AND assoc_id = ? AND load_id = ?
ORDER BY day DESC
LIMIT 1',
array((int) $assocType, (int) $assocId, $loadId)); // Not number.
WHERE assoc_type = ? AND assoc_id = ? AND entry_time = ? AND load_id = ?',
array((int) $assocType, (int) $assocId, (int) $time, $loadId)); // Not number.
}


Expand Down
3 changes: 3 additions & 0 deletions plugins/generic/usageStats/schema.xml
Expand Up @@ -39,6 +39,9 @@
<NOTNULL/>
</field>
<field name="file_type" type="I1" />
<field name="entry_time" type="I8">
<NOTNULL/>
</field>
<descr>Usage stats temporary records</descr>
</table>
</schema>

0 comments on commit fb069c2

Please sign in to comment.