Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

Commit

Permalink
Merge pull request #128 from ks888/rss-feed
Browse files Browse the repository at this point in the history
Fix the wrong link to maintenance
  • Loading branch information
ks888 authored Jun 28, 2018
2 parents c4e673a + 8a1e4cb commit ba950df
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/lambda/src/api/updateFeeds/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function handle (event, context, callback) {

export const buildFeed = async (serviceName, statusPageURL) => {
const feed = new Feed({
id: `tag:${statusPageURL},2017:/history`,
id: `tag:${statusPageURL},2018:/history`,
link: statusPageURL,
title: `[${serviceName} Status] Incident History`,
author: {
Expand Down Expand Up @@ -81,8 +81,8 @@ export const buildMaintenanceItems = async statusPageURL => {
}

export const buildItem = async (event, eventUpdatesStore, statusPageURL) => {
const id = `tag:${statusPageURL},2017:Incident/${event.getEventID()}`
const link = `${statusPageURL.replace(/\/$/, '')}/incidents/${event.getEventID()}`
const id = `tag:${statusPageURL},2018:${event.getEventID()}`
const link = `${statusPageURL.replace(/\/$/, '')}${event.getURLPath()}`
const date = new Date(event.getCreatedAt())
const title = event.getName()

Expand Down
4 changes: 4 additions & 0 deletions packages/lambda/src/model/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export class Event {
throw new Error('not implemented')
}

getURLPath () {
throw new Error('not implemented')
}

getName () {
throw new Error('not implemented')
}
Expand Down
4 changes: 4 additions & 0 deletions packages/lambda/src/model/incidents.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export class Incident extends Event {
this.incidentID = incidentID
}

getURLPath () {
return `/incidents/${this.getEventID()}`
}

getName () {
return this.name
}
Expand Down
4 changes: 4 additions & 0 deletions packages/lambda/src/model/maintenances.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export class Maintenance extends Event {
this.maintenanceID = maintenanceID
}

getURLPath () {
return `/maintenances/${this.getEventID()}`
}

getName () {
return this.name
}
Expand Down
4 changes: 2 additions & 2 deletions packages/lambda/test/api/updateFeeds/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('updateFeeds', () => {
describe('buildFeed', () => {
it('should build the feed', async () => {
const feed = await buildFeed(serviceName, statusPageURL)
assert(feed.options.id === 'tag:https://xxx.cloudfront.net,2017:/history')
assert(feed.options.id === 'tag:https://xxx.cloudfront.net,2018:/history')
assert(feed.options.link === statusPageURL)
assert(feed.options.title === '[Test Status] Incident History')
assert(feed.options.author.name === serviceName)
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('updateFeeds', () => {
it('should build the feed item which represents the one incident and its updates', async () => {
const item = await buildItem(event, new IncidentUpdatesStore(), statusPageURL)

assert(item.id === `tag:https://xxx.cloudfront.net,2017:Incident/1`)
assert(item.id === `tag:https://xxx.cloudfront.net,2018:1`)
assert(item.link === `https://xxx.cloudfront.net/incidents/1`)
assert(item.content === `<p><small>Jan 1, 2018, 00:00 UTC</small><br><strong>Investigating</strong> - test</p>`)
assert(item.published.toISOString() === eventUpds[0].createdAt)
Expand Down

0 comments on commit ba950df

Please sign in to comment.