fix channel subs null value extraction, #803

This commit is contained in:
Simon 2025-05-11 10:15:58 +07:00
parent c5f212f520
commit e34da1687e
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
3 changed files with 15 additions and 3 deletions

View File

@ -157,8 +157,18 @@ class YoutubeChannel(YouTubeItem):
# add ingest pipeline
processors = []
for field, value in self.json_data.items():
line = {"set": {"field": "channel." + field, "value": value}}
if value is None:
line = {
"script": {
"lang": "painless",
"source": f"ctx['{field}'] = null;",
}
}
else:
line = {"set": {"field": "channel." + field, "value": value}}
processors.append(line)
data = {"description": self.youtube_id, "processors": processors}
ingest_path = f"_ingest/pipeline/{self.youtube_id}"
_, _ = ElasticWrap(ingest_path).put(data)

View File

@ -49,7 +49,9 @@ const ChannelList = ({ channelList, refreshChannelList }: ChannelListProps) => {
<h3>
<Link to={Routes.Channel(channel.channel_id)}>{channel.channel_name}</Link>
</h3>
<FormattedNumber text="Subscribers:" number={channel.channel_subs} />
{channel.channel_subs !== null && (
<FormattedNumber text="Subscribers:" number={channel.channel_subs} />
)}
</div>
</div>
<div className="info-box-item">

View File

@ -38,7 +38,7 @@ const ChannelOverview = ({
<Link to={Routes.ChannelVideo(channelId)}>{channelname}</Link>
</h3>
<FormattedNumber text="Subscribers:" number={channelSubs} />
{channelSubs !== null && <FormattedNumber text="Subscribers:" number={channelSubs} />}
{isAdmin && (
<>