Skip to content

Add aggregates meta tags#62

Merged
emhoracek merged 13 commits intomasterfrom
add-aggregates-meta-tags
Oct 29, 2018
Merged

Add aggregates meta tags#62
emhoracek merged 13 commits intomasterfrom
add-aggregates-meta-tags

Conversation

@emhoracek
Copy link
Member

No description provided.

Instead of everything directly instead of wpPostsAggregate repeating with
each post, instead it repeats the content inside of a wpPostsItem blank.
This will allow for a wpPostsMeta that doesn't repeat.
This allows us to re-export commonly used imported types, like
ResponseHeaders.
@emhoracek emhoracek force-pushed the add-aggregates-meta-tags branch from d95f8db to 2105d5b Compare October 26, 2018 18:03
spec/Common.hs Outdated

fauxRequester :: Maybe (MVar [Text]) -> Text -> [(Text, Text)] -> IO (Either StatusCode Text)
toWPResp :: (Text, H.ResponseHeaders) -> IO (Either StatusCode WPResponse)
toWPResp (body, headers) = return $ Right $ WPResponse headers body
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's confusing to see (body, headers) followed by headers body on the right hand side. I think standardizing on an order across the codebase is valuable. I would suggest headers and then body since that's the order the request has them from top to bottom.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, originally it was just easier to paste , mempty) to the end of the line, but then I just made the toWPResp helper anyway. I should just make the helper add empty headers since they're empty for most of the tests.

spec/Main.hs Outdated
main = runTests

deadTests :: Spec
deadTests = do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this name is because...?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a liveTests that is tests of a live server. I'll change the name XD

else
do o <- wpRequest wpKey
case o of
do resp <- wpRequest wpKey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm imagining putting this in production and it retrieving a key from an older cached WP request that has no headers. Where will it fail to decode into a WPResponse and what will happen? We should either have a plan to explicitly clear the cache when we deploy this or be backwards compatible w/r/t the payloads already cached in Redis.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, good thinking. I can add a fallback in the ToJSON implementation to avoid that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant FromJSON above. Added a fallback. It turns out you can write things like v .:? "some_field" .!= "some default text" which means, try to find some field, and if you can't find it, use this default.

@emhoracek
Copy link
Member Author

@dhartunian I used your suggestions -- take another look?

@emhoracek emhoracek merged commit 054055d into master Oct 29, 2018
@emhoracek emhoracek deleted the add-aggregates-meta-tags branch October 29, 2018 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants