Skip to content

Commit

Permalink
update: 最新の200件だけインデックス登録するように
Browse files Browse the repository at this point in the history
  • Loading branch information
yamadashy committed May 18, 2022
1 parent 63d88c3 commit 8c12d4a
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/feed/register-index-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,29 @@ import { BlogFeed } from './utils/feed-storer';
import * as constants from '../common/constants';
import { sleep } from './utils/common-util';
const key = require('../../storage/service_account.json');
const blogFeeds: BlogFeed[] = require('../site/blog-feeds/blog-feeds.json');
let blogFeeds: BlogFeed[] = require('../site/blog-feeds/blog-feeds.json');

const indexTargetUrls = blogFeeds.map((blogFeed) => {
return `${constants.siteUrlStem}/${blogFeed.linkMd5Hash}/`;
});
const GOOGLE_INDEXING_API_END_POINT = 'https://indexing.googleapis.com/v3/urlNotifications:publish';
const INDEXING_LIMIT = 200;

// ソート
blogFeeds = blogFeeds.sort((a, b) => {
const aLastUpdated = a.items[0]?.isoDate;
const bLastUpdated = b.items[0]?.isoDate;

if (!aLastUpdated) {
return 1;
}
if (!bLastUpdated) {
return -1;
}

return -1 * aLastUpdated.localeCompare(bLastUpdated);
});

const indexTargetUrls = blogFeeds.slice(0, INDEXING_LIMIT).map((blogFeed) => {
return `${constants.siteUrlStem}/blogs/${blogFeed.linkMd5Hash}/`;
});

const jwtClient = new google.auth.JWT({
email: key.client_email,
Expand Down

0 comments on commit 8c12d4a

Please sign in to comment.