Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding story topics from story settings page #15

Open
aliabbasjaffri opened this issue Sep 24, 2022 · 2 comments
Open

Adding story topics from story settings page #15

aliabbasjaffri opened this issue Sep 24, 2022 · 2 comments

Comments

@aliabbasjaffri
Copy link

It would be awesome to get the story topics for a specific story as it makes it easer to see which story topics were getting the most traction during a given time. It would then help any user to focus on content around the topics which are getting the most hits.

Story topics can be fetched from : https://medium.com/p/<POST_ID>/settings

I would be glad to contribute towards this issue. Would really appreciate if you can push me in the right direction.

@aliabbasjaffri
Copy link
Author

Completely forgot to mention: awesome job creating this utility! I was trying to reinvent the wheel at my end, untill i stumbled across this package. The recreation of cookie from uid and sid is a solid effort and really applause deserving!

@otosky
Copy link
Owner

otosky commented Oct 15, 2022

thanks for the kind words @aliabbasjaffri and sorry for the delayed response!

I did a little digging around and found the GraphQL fragment for Tag that another query on the homepage makes when fetching recommended articles.

You can edit this query to bundle the tags with each post like so:

query StatsPostChart($postId: ID!, $startAt: Long!, $endAt: Long!) {
    post(id: $postId) {
      id
      ...StatsPostChart_dailyStats
      ...StatsPostChart_dailyEarnings
      __typename
      tags { 
          ...Topic_tag
          __typename
      }
    }
  }
    
  fragment Topic_tag on Tag {
      __typename
      id
      displayTitle
      normalizedTagSlug
  }

  fragment StatsPostChart_dailyStats on Post {
    dailyStats(startAt: $startAt, endAt: $endAt) {
      periodStartedAt
      views
      internalReferrerViews
      memberTtr
      __typename
    }
    __typename
  }
    
  fragment StatsPostChart_dailyEarnings on Post {
    earnings {
      dailyEarnings(startAt: $startAt, endAt: $endAt) {
        periodEndedAt
        periodStartedAt
        amount
        __typename
      }
      lastCommittedPeriodStartedAt
      __typename
    }
    __typename
  }

There are a bunch of changes that I'd like to make to this lib in order to make it easier to contribute to, but I've been slow to finish/integrate. If you're ok to wait for that, I'd prefer to make those updates before adding anything else to this version.

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

No branches or pull requests

2 participants