mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Revert changes
This commit is contained in:
1 parent
b9aa1351c9
commit
31e42252e6
1 file changed
+32
-21
@@ -262,32 +262,43 @@ class TablesDB extends TimeLimit
|
||||
{
|
||||
$timestamp = $this->toDateTime($timestamp);
|
||||
|
||||
$data = [
|
||||
'key' => $key,
|
||||
'time' => $timestamp,
|
||||
'count' => $value,
|
||||
];
|
||||
$response = $this->tablesDB->listRows($this->databaseId, self::TABLE_ID, [
|
||||
Query::equal('key', [$key]),
|
||||
Query::equal('time', [$timestamp]),
|
||||
]);
|
||||
$rows = $response['rows'];
|
||||
$data = $rows[0] ?? null;
|
||||
|
||||
try {
|
||||
$this->tablesDB->createRow($this->databaseId, self::TABLE_ID, ID::unique(), $data);
|
||||
} catch (AppwriteException $err) {
|
||||
if ($err->getType() !== 'row_already_exists') {
|
||||
throw $err;
|
||||
}
|
||||
if (\is_null($data)) {
|
||||
$data = [
|
||||
'key' => $key,
|
||||
'time' => $timestamp,
|
||||
'count' => $value,
|
||||
];
|
||||
|
||||
$response = $this->tablesDB->listRows($this->databaseId, self::TABLE_ID, [
|
||||
Query::equal('key', [$key]),
|
||||
Query::equal('time', [$timestamp]),
|
||||
]);
|
||||
$rows = $response['rows'];
|
||||
try {
|
||||
$this->tablesDB->createRow($this->databaseId, self::TABLE_ID, ID::unique(), $data);
|
||||
} catch (AppwriteException $err) {
|
||||
if ($err->getType() !== 'row_already_exists') {
|
||||
throw $err;
|
||||
}
|
||||
|
||||
$data = $rows[0] ?? null;
|
||||
$response = $this->tablesDB->listRows($this->databaseId, self::TABLE_ID, [
|
||||
Query::equal('key', [$key]),
|
||||
Query::equal('time', [$timestamp]),
|
||||
]);
|
||||
$rows = $response['rows'];
|
||||
|
||||
if (!is_null($data)) {
|
||||
$this->tablesDB->updateRow($this->databaseId, self::TABLE_ID, $data['$id'], ['count' => $value]);
|
||||
} else {
|
||||
throw new \Exception('Unable to find abuse tracking row after race condition handling');
|
||||
$data = $rows[0] ?? null;
|
||||
|
||||
if (!is_null($data)) {
|
||||
$this->tablesDB->updateRow($this->databaseId, self::TABLE_ID, $data['$id'], ['count' => $value]);
|
||||
} else {
|
||||
throw new \Exception('Unable to find abuse tracking row after race condition handling');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->tablesDB->updateRow($this->databaseId, self::TABLE_ID, $data['$id'], ['count' => $value]);
|
||||
}
|
||||
|
||||
$this->count = $value;
|
||||
|
||||
Reference in new issue
Block a user