Skip to content

Commit 15cd5db

Browse files
authored
Merge pull request #108 from utopia-php/chore-update-database
2 parents 3339d05 + b7fc951 commit 15cd5db

File tree

3 files changed

+45
-47
lines changed

3 files changed

+45
-47
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"ext-pdo": "*",
2323
"ext-curl": "*",
2424
"ext-redis": "*",
25-
"utopia-php/database": "3.*.*",
26-
"appwrite/appwrite": "19.*.*"
25+
"utopia-php/database": "4.*",
26+
"appwrite/appwrite": "19.*"
2727
},
2828
"require-dev": {
2929
"phpunit/phpunit": "9.*",

composer.lock

Lines changed: 38 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Abuse/Adapters/TimeLimit/Database.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Utopia\Database\Exception\Duplicate;
1111
use Utopia\Database\Exception\Structure;
1212
use Utopia\Database\Query;
13-
use Utopia\Database\Validator\Authorization;
1413
use Utopia\Exception;
1514

1615
class Database extends TimeLimit
@@ -139,7 +138,7 @@ protected function count(string $key, int $timestamp): int
139138
$timestamp = $this->toDateTime($timestamp);
140139

141140
/** @var array<Document> $result */
142-
$result = Authorization::skip(function () use ($key, $timestamp) {
141+
$result = $this->db->getAuthorization()->skip(function () use ($key, $timestamp) {
143142
return $this->db->find(self::COLLECTION, [
144143
Query::equal('key', [$key]),
145144
Query::equal('time', [$timestamp]),
@@ -172,7 +171,7 @@ protected function hit(string $key, int $timestamp): void
172171
}
173172

174173
$timestamp = $this->toDateTime($timestamp);
175-
Authorization::skip(function () use ($timestamp, $key) {
174+
$this->db->getAuthorization()->skip(function () use ($timestamp, $key) {
176175
$data = $this->db->findOne(self::COLLECTION, [
177176
Query::equal('key', [$key]),
178177
Query::equal('time', [$timestamp]),
@@ -226,7 +225,7 @@ protected function hit(string $key, int $timestamp): void
226225
protected function set(string $key, int $timestamp, int $value): void
227226
{
228227
$timestamp = $this->toDateTime($timestamp);
229-
Authorization::skip(function () use ($timestamp, $key, $value) {
228+
$this->db->getAuthorization()->skip(function () use ($timestamp, $key, $value) {
230229
$data = $this->db->findOne(self::COLLECTION, [
231230
Query::equal('key', [$key]),
232231
Query::equal('time', [$timestamp]),
@@ -284,7 +283,7 @@ protected function set(string $key, int $timestamp, int $value): void
284283
public function getLogs(?int $offset = null, ?int $limit = 25): array
285284
{
286285
/** @var array<Document> $results */
287-
$results = Authorization::skip(function () use ($offset, $limit) {
286+
$results = $this->db->getAuthorization()->skip(function () use ($offset, $limit) {
288287
$queries = [];
289288
$queries[] = Query::orderDesc('');
290289

@@ -312,7 +311,7 @@ public function getLogs(?int $offset = null, ?int $limit = 25): array
312311
public function cleanup(int $timestamp): bool
313312
{
314313
$timestamp = $this->toDateTime($timestamp);
315-
Authorization::skip(function () use ($timestamp) {
314+
$this->db->getAuthorization()->skip(function () use ($timestamp) {
316315
do {
317316
$documents = $this->db->find(self::COLLECTION, [
318317
Query::lessThan('time', $timestamp),

0 commit comments

Comments
 (0)