mirror of
https://github.com/norohind/FDEV-CAPI-Handler.git
synced 2026-10-27 01:16:03 +03:00
Introduce mechanism to skip token use counter update
This commit is contained in:
2 files changed
+6
-2
No files matched your search
+4
-2
@@ -1,6 +1,7 @@
|
||||
import sqlite3
|
||||
from typing import Union
|
||||
|
||||
import config
|
||||
from . import sqlite_requests
|
||||
from EDMCLogging import get_main_logger
|
||||
|
||||
@@ -129,8 +130,9 @@ class Model:
|
||||
def get_token_for_user(self, state: str) -> dict:
|
||||
sql_params = {'state': state}
|
||||
token = self.db.execute(sqlite_requests.get_token_for_user, sql_params).fetchone()
|
||||
with self.db:
|
||||
self.db.execute(sqlite_requests.increment_usages, sql_params)
|
||||
if not config.do_skip_token_usage_increment:
|
||||
with self.db:
|
||||
self.db.execute(sqlite_requests.increment_usages, sql_params)
|
||||
|
||||
return token
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ from os import getenv
|
||||
CLIENT_ID = getenv('client_id')
|
||||
assert CLIENT_ID, "No client_id in env"
|
||||
|
||||
do_skip_token_usage_increment = os.getenv('SKIP_INCREMENT', 'false').lower() in ('true', 't', '1')
|
||||
|
||||
log_level = os.getenv('LOG_LEVEL', 'DEBUG').upper()
|
||||
|
||||
access_key = os.getenv('access_key')
|
||||
|
||||
Reference in new issue
Block a user