mzivil f59ee5df17
Add ranked territories to 'top' page (#828)
* add subViewGroup function to create view to read sub stats from

* add topSubs resolver to graphql query

* add TOP_SUBS query fragment

* add SUB_SORTS for top territory sorting

* add custom cache policy for topSubs

* add territories to top header select

* add top territories page

* add db views for sub stats

* configure sub_stats views to refresh by worker

* filter rows with empty subName

* update msats_spent calculation to include all ItemAct in sub

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-02-14 14:27:00 -06:00

60 lines
1.5 KiB
JavaScript

import { gql } from 'graphql-tag'
export default gql`
extend type Query {
sub(name: String): Sub
subLatestPost(name: String!): String
subs: [Sub!]!
topSubs(cursor: String, when: String, from: String, to: String, by: String, limit: Limit): Subs
}
type Subs {
cursor: String
subs: [Sub!]!
}
extend type Mutation {
upsertSub(oldName: String, name: String!, desc: String, baseCost: Int!,
postTypes: [String!]!, allowFreebies: Boolean!,
billingType: String!, billingAutoRenew: Boolean!,
moderated: Boolean!, hash: String, hmac: String, nsfw: Boolean!): Sub
paySub(name: String!, hash: String, hmac: String): Sub
toggleMuteSub(name: String!): Boolean!
}
type Sub {
name: ID!
createdAt: Date!
userId: Int!
user: User!
desc: String
updatedAt: Date!
postTypes: [String!]!
allowFreebies: Boolean!
billingCost: Int!
billingType: String!
billingAutoRenew: Boolean!
rankingType: String!
billedLastAt: Date!
baseCost: Int!
status: String!
moderated: Boolean!
moderatedCount: Int!
meMuteSub: Boolean!
nsfw: Boolean!
nposts(when: String, from: String, to: String): Int!
ncomments(when: String, from: String, to: String): Int!
optional: SubOptional!
}
type SubOptional {
"""
conditionally private
"""
stacked(when: String, from: String, to: String): Int
spent(when: String, from: String, to: String): Int
revenue(when: String, from: String, to: String): Int
}
`