Skip to content

Commit

Permalink
improve: Refresh updated_at field of DataSourceOauthBinding model (#9173
Browse files Browse the repository at this point in the history
)

Signed-off-by: Xiaoguang Sun <sunxiaoguang@gmail.com>
  • Loading branch information
sunxiaoguang authored Oct 10, 2024
1 parent 75f0a5e commit be2f1e5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/libs/oauth_data_source.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import urllib.parse

import requests
Expand Down Expand Up @@ -69,6 +70,7 @@ def get_access_token(self, code: str):
if data_source_binding:
data_source_binding.source_info = source_info
data_source_binding.disabled = False
data_source_binding.updated_at = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None)
db.session.commit()
else:
new_data_source_binding = DataSourceOauthBinding(
Expand Down Expand Up @@ -104,6 +106,7 @@ def save_internal_access_token(self, access_token: str):
if data_source_binding:
data_source_binding.source_info = source_info
data_source_binding.disabled = False
data_source_binding.updated_at = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None)
db.session.commit()
else:
new_data_source_binding = DataSourceOauthBinding(
Expand Down Expand Up @@ -138,6 +141,7 @@ def sync_data_source(self, binding_id: str):
}
data_source_binding.source_info = new_source_info
data_source_binding.disabled = False
data_source_binding.updated_at = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None)
db.session.commit()
else:
raise ValueError("Data source binding not found")
Expand Down

0 comments on commit be2f1e5

Please sign in to comment.