Skip to content

Commit

Permalink
fix: new timeline value (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 authored Dec 17, 2023
1 parent 57d7b16 commit 2d562e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
4 changes: 0 additions & 4 deletions chii/timeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ class SubjectMemo(BaseModel):
collect_comment: str
collect_rate: int
subject_id: str
subject_name: str
subject_name_cn: str
subject_series: bool = False
subject_type_id: str


class SubjectImage(BaseModel):
Expand Down
24 changes: 8 additions & 16 deletions rpc/timeline_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import html
import time
from typing import Optional
from typing import Any, Optional

import phpserialize as php
import pydantic
Expand Down Expand Up @@ -31,12 +31,10 @@
TimelineCat,
)

BatchMeme: pydantic.TypeAdapter[dict[int, SubjectMemo]] = pydantic.TypeAdapter(
dict[int, SubjectMemo]
)
BatchMeme: pydantic.TypeAdapter[dict[int, Any]] = pydantic.TypeAdapter(dict[int, Any])

BatchSubjectImage: pydantic.TypeAdapter[dict[int, SubjectImage]] = pydantic.TypeAdapter(
dict[int, SubjectImage]
BatchSubjectImage: pydantic.TypeAdapter[dict[int, Any]] = pydantic.TypeAdapter(
dict[int, Any]
)


Expand Down Expand Up @@ -77,8 +75,9 @@ def SubjectCollect(

return SubjectCollectResponse(ok=True)

@staticmethod
def merge_previous_timeline(
self, session: Session, tl: ChiiTimeline, req: SubjectCollectRequest
session: Session, tl: ChiiTimeline, req: SubjectCollectRequest
):
escaped = html.escape(req.comment)
if tl.batch:
Expand All @@ -105,10 +104,6 @@ def merge_previous_timeline(

memo[req.subject.id] = SubjectMemo(
subject_id=str(req.subject.id),
subject_type_id=str(req.subject.type),
subject_name_cn=req.subject.name_cn,
subject_series=req.subject.series,
subject_name=req.subject.name,
collect_comment=escaped,
collect_rate=req.rate,
)
Expand All @@ -131,15 +126,12 @@ def merge_previous_timeline(

session.add(tl)

@staticmethod
def create_subject_collection_timeline(
self, session: Session, req: SubjectCollectRequest, type: int
session: Session, req: SubjectCollectRequest, type: int
):
memo = SubjectMemo(
subject_id=str(req.subject.id),
subject_type_id=str(req.subject.type),
subject_name_cn=req.subject.name_cn,
subject_series=req.subject.series,
subject_name=req.subject.name,
collect_comment=html.escape(req.comment),
collect_rate=req.rate,
)
Expand Down

0 comments on commit 2d562e9

Please sign in to comment.