Skip to content

Commit

Permalink
Add created_at to apps/plugins model (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
beastoin authored Nov 11, 2024
2 parents d19c11a + 27a7b58 commit bc4c42e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions backend/models/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class App(BaseModel):
trigger_workflow_memories: bool = True # default true
installs: int = 0
proactive_notification: Optional[ProactiveNotification] = None
created_at: Optional[datetime] = None

def get_rating_avg(self) -> Optional[str]:
return f'{self.rating_avg:.1f}' if self.rating_avg is not None else None
Expand Down
1 change: 1 addition & 0 deletions backend/models/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Plugin(BaseModel):
trigger_workflow_memories: bool = True # default true
installs: int = 0
proactive_notification: Optional[ProactiveNotification] = None
created_at: Optional[datetime] = None

def get_rating_avg(self) -> Optional[str]:
return f'{self.rating_avg:.1f}' if self.rating_avg is not None else None
Expand Down
2 changes: 2 additions & 0 deletions backend/routers/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import random
from datetime import datetime, timezone
from typing import List
import requests
from fastapi import APIRouter, Depends, Form, UploadFile, File, HTTPException, Header
Expand Down Expand Up @@ -66,6 +67,7 @@ def submit_app(app_data: str = Form(...), file: UploadFile = File(...), uid=Depe
f.write(file.file.read())
imgUrl = upload_plugin_logo(file_path, data['id'])
data['image'] = imgUrl
data['created_at'] = datetime.now(timezone.utc)
if data.get('private', True):
print("Adding private app")
add_private_app(data, data['uid'])
Expand Down
6 changes: 4 additions & 2 deletions backend/routers/plugins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import random
from datetime import datetime, timezone
from collections import defaultdict
from typing import List

Expand Down Expand Up @@ -55,12 +56,12 @@ def get_plugins(uid: str):


@router.get('/v1/plugins', tags=['v1'])
def get_plugins(uid: str):
def get_plugins_v1(uid: str):
return get_plugins_data(uid, include_reviews=True)


@router.get('/v2/plugins', tags=['v1'], response_model=List[Plugin])
def get_plugins(uid: str = Depends(auth.get_current_user_uid)):
def get_plugins_v2(uid: str = Depends(auth.get_current_user_uid)):
return get_plugins_data(uid, include_reviews=True)


Expand Down Expand Up @@ -151,6 +152,7 @@ def add_plugin(plugin_data: str = Form(...), file: UploadFile = File(...), uid=D
f.write(file.file.read())
imgUrl = upload_plugin_logo(file_path, data['id'])
data['image'] = imgUrl
data['created_at'] = datetime.now(timezone.utc)
if data.get('private', True):
print("Adding private plugin")
add_private_plugin(data, data['uid'])
Expand Down

0 comments on commit bc4c42e

Please sign in to comment.