mirror of
https://github.com/nexus-stc/hyperboria
synced 2025-01-11 19:25:53 +01:00
dd23846059
- [nexus] Switch bot - [bot] Added extra receivers functionality GitOrigin-RevId: 68fc32d3e79ff411758f54f435fe8680fc42dead
35 lines
1016 B
Python
35 lines
1016 B
Python
import orjson as json
|
|
from izihawa_utils.common import filter_none
|
|
from nexus.models.proto.scimag_pb2 import Scimag as ScimagPb
|
|
from summa.proto.proto_grpc_py_pb import index_pb2 as index_pb
|
|
|
|
from .base import BaseAction
|
|
|
|
|
|
class ToThinScimagPbAction(BaseAction):
|
|
async def do(self, item: dict) -> ScimagPb:
|
|
return ScimagPb(doi=item['doi'])
|
|
|
|
|
|
class ScitechToIndexOperationBytesAction(BaseAction):
|
|
restricted_column_set = [
|
|
'extension',
|
|
'fiction_id',
|
|
'filesize',
|
|
'has_duplicates',
|
|
'ipfs_multihashes',
|
|
'libgen_id',
|
|
'md5',
|
|
'original_id',
|
|
]
|
|
|
|
async def do(self, item: dict) -> bytes:
|
|
# if item['original_id'] is not None:
|
|
# item = {rc: item[rc] for rc in self.restricted_column_set}
|
|
return index_pb.IndexOperation(
|
|
index_document=index_pb.IndexDocumentOperation(
|
|
document=json.dumps(filter_none(item)),
|
|
reindex=True,
|
|
),
|
|
).SerializeToString()
|