Skip to content

Commit

Permalink
feat: 升级到 sshared v0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FHU-yezi committed Jun 23, 2024
1 parent e32b85b commit de783b8
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 458 deletions.
8 changes: 4 additions & 4 deletions models/jianshu/article_earning_ranking_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
PositiveInt,
UserSlug,
)
from sshared.mongo import MODEL_META, Document, Field, Index
from sshared.mongo import Document, Field, Index

from utils.db import JIANSHU_DB


class ArticleField(Field, **MODEL_META):
class ArticleField(Field, frozen=True):
slug: Optional[ArticleSlug]
title: Optional[NonEmptyStr]


class EarningField(Field, **MODEL_META):
class EarningField(Field, frozen=True):
to_author: PositiveFloat
to_voter: PositiveFloat


class ArticleEarningRankingRecordDocument(Document, **MODEL_META):
class ArticleEarningRankingRecordDocument(Document, frozen=True):
date: datetime
ranking: PositiveInt

Expand Down
6 changes: 3 additions & 3 deletions models/jianshu/assets_ranking_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
PositiveInt,
UserSlug,
)
from sshared.mongo import MODEL_META, Document, Field, Index
from sshared.mongo import Document, Field, Index

from utils.db import JIANSHU_DB


class AmountField(Field, **MODEL_META):
class AmountField(Field, frozen=True):
fp: Optional[NonNegativeFloat]
ftn: Optional[NonNegativeFloat]
assets: Optional[PositiveFloat]


class AssetsRankingRecordDocument(Document, **MODEL_META):
class AssetsRankingRecordDocument(Document, frozen=True):
date: datetime
ranking: PositiveInt

Expand Down
4 changes: 2 additions & 2 deletions models/jianshu/daily_update_ranking_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
PositiveInt,
UserSlug,
)
from sshared.mongo import MODEL_META, Document, Index
from sshared.mongo import Document, Index

from utils.db import JIANSHU_DB


class DailyUpdateRankingRecordDocument(Document, **MODEL_META):
class DailyUpdateRankingRecordDocument(Document, frozen=True):
date: datetime
ranking: PositiveInt
days: PositiveInt
Expand Down
4 changes: 2 additions & 2 deletions models/jianshu/lottery_win_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
PositiveInt,
UserSlug,
)
from sshared.mongo import MODEL_META, Document, Index
from sshared.mongo import Document, Index

from utils.db import JIANSHU_DB


class LotteryWinRecordDocument(Document, **MODEL_META):
class LotteryWinRecordDocument(Document, frozen=True):
id: PositiveInt
time: datetime
award_name: NonEmptyStr
Expand Down
4 changes: 2 additions & 2 deletions models/jianshu/lp_recommend_article_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
UserSlug,
)
from msgspec import field
from sshared.mongo import MODEL_META, Document, Index
from sshared.mongo import Document, Index

from utils.db import JIANSHU_DB


class LPRecommendedArticleRecordDocument(Document, **MODEL_META):
class LPRecommendedArticleRecordDocument(Document, frozen=True):
date: datetime
id: PositiveInt
slug: ArticleSlug
Expand Down
4 changes: 2 additions & 2 deletions models/jianshu/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any, Dict, List, Optional

from jkit.msgspec_constraints import PositiveInt, UserName, UserSlug, UserUploadedUrl
from sshared.mongo import MODEL_META, Document, Index
from sshared.mongo import Document, Index

from utils.db import JIANSHU_DB

Expand All @@ -13,7 +13,7 @@ class JianshuUserStatus(Enum):
INACCESSABLE = "INACCESSIBLE"


class UserDocument(Document, **MODEL_META):
class UserDocument(Document, frozen=True):
slug: UserSlug
status: JianshuUserStatus
updated_at: datetime
Expand Down
4 changes: 2 additions & 2 deletions models/jpep/credit_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from typing import Optional

from jkit.msgspec_constraints import NonNegativeInt, PositiveInt
from sshared.mongo import MODEL_META, Document, Index
from sshared.mongo import Document, Index

from utils.db import JPEP_DB


class CreditHistoryDocument(Document, **MODEL_META):
class CreditHistoryDocument(Document, frozen=True):
time: datetime
user_id: PositiveInt
value: NonNegativeInt
Expand Down
6 changes: 3 additions & 3 deletions models/jpep/ftn_trade_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
PositiveFloat,
PositiveInt,
)
from sshared.mongo import MODEL_META, Document, Field, Index
from sshared.mongo import Document, Field, Index

from utils.db import JPEP_DB


class AmountField(Field, **MODEL_META):
class AmountField(Field, frozen=True):
total: PositiveInt
traded: NonNegativeInt
tradable: NonNegativeInt
minimum_trade: PositiveInt


class FTNTradeOrderDocument(Document, **MODEL_META):
class FTNTradeOrderDocument(Document, frozen=True):
fetch_time: datetime
id: PositiveInt
published_at: datetime
Expand Down
6 changes: 3 additions & 3 deletions models/jpep/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
from typing import Any, Dict, Optional

from jkit.msgspec_constraints import NonNegativeInt, PositiveInt
from sshared.mongo import MODEL_META, Document, Field, Index
from sshared.mongo import Document, Field, Index

from utils.db import JPEP_DB


class CreditHistoryFieldItem(Field, **MODEL_META):
class CreditHistoryFieldItem(Field, frozen=True):
time: datetime
value: NonNegativeInt


class UserDocument(Document):
class UserDocument(Document, frozen=True):
updated_at: datetime
id: PositiveInt
name: str
Expand Down
Loading

0 comments on commit de783b8

Please sign in to comment.