diff --git a/tildes/openapi_beta.yaml b/tildes/openapi_beta.yaml index ebf5ead..b35b2df 100644 --- a/tildes/openapi_beta.yaml +++ b/tildes/openapi_beta.yaml @@ -23,7 +23,7 @@ paths: type: string default: "all" required: false - description: The time period for which to retrieve topics. For example 4h" or "2d". + description: The time period for which to retrieve topics. For example "4h" or "2d". - in: query name: tag schema: @@ -264,6 +264,7 @@ components: - group - content_metadata - created_at + - edited_at - posted_by_user - vote_count - comment_count @@ -301,6 +302,9 @@ components: type: string created_at: type: string + edited_at: + type: string + nullable: true posted_by_user: type: string vote_count: diff --git a/tildes/tildes/lib/database.py b/tildes/tildes/lib/database.py index b28e397..fae0253 100644 --- a/tildes/tildes/lib/database.py +++ b/tildes/tildes/lib/database.py @@ -179,7 +179,7 @@ class RecurrenceRule(TypeDecorator): if value is None: return value - return rrulestr(value) # type: ignore + return rrulestr(value) class TagList(TypeDecorator): diff --git a/tildes/tildes/views/api/beta/api_utils.py b/tildes/tildes/views/api/beta/api_utils.py index 9cb429b..e997f07 100644 --- a/tildes/tildes/views/api/beta/api_utils.py +++ b/tildes/tildes/views/api/beta/api_utils.py @@ -11,7 +11,10 @@ from tildes.models.pagination import PaginatedQuery, PaginatedResults def query_apply_pagination( # noqa - query, before, after, error_if_no_anchor: bool = False + query: PaginatedQuery, + before: str | None, + after: str | None, + error_if_no_anchor: bool = False, ) -> PaginatedQuery: """Apply pagination parameters to a query.""" # Start by parsing the before/after parameters and extracting the anchor type @@ -46,7 +49,9 @@ def query_apply_pagination( # noqa return query -def get_next_and_prev_link(request: Request, page: PaginatedResults) -> Tuple[str, str]: +def get_next_and_prev_link( + request: Request, page: PaginatedResults +) -> Tuple[str | None, str | None]: """Get the next and previous links for pagination.""" next_link = None prev_link = None diff --git a/tildes/tildes/views/api/beta/topic.py b/tildes/tildes/views/api/beta/topic.py index 5c0020c..b8c87f3 100644 --- a/tildes/tildes/views/api/beta/topic.py +++ b/tildes/tildes/views/api/beta/topic.py @@ -30,6 +30,9 @@ def topic_to_dict(topic: Topic) -> dict: "group": str(topic.group.path), "content_metadata": topic.content_metadata_for_display, "created_at": topic.created_time.isoformat(), + "edited_at": ( + topic.last_edited_time.isoformat() if topic.last_edited_time else None + ), "posted_by_user": topic.user.username, "vote_count": topic.num_votes, "comment_count": topic.num_comments, diff --git a/tildes/tildes/views/api/beta/user.py b/tildes/tildes/views/api/beta/user.py index cdbdda7..3b5b865 100644 --- a/tildes/tildes/views/api/beta/user.py +++ b/tildes/tildes/views/api/beta/user.py @@ -3,6 +3,7 @@ """JSON API endpoints related to users.""" +from typing import Union from pyramid.request import Request from pyramid.view import view_config from tildes.models.user.user import User @@ -62,7 +63,8 @@ def get_user(request: Request) -> dict: # noqa result_sets = [] # For the main user API endpoint, combine topics and comments - for type_to_query in [Topic, Comment]: + types_to_query: list[Union[type[Topic], type[Comment]]] = [Topic, Comment] + for type_to_query in types_to_query: query = request.query(type_to_query).filter(type_to_query.user == user) try: query = query_apply_pagination(