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

Sort backed projects by end date #2069

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
256 changes: 106 additions & 150 deletions KsApi/GraphAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8427,23 +8427,20 @@ public enum GraphAPI {
public let operationDefinition: String =
"""
query FetchMyBackedProjects($first: Int = null, $after: String = null, $withStoredCards: Boolean = false) {
me {
projects(first: $first, after: $after, backed: true, sort: END_DATE) {
__typename
backingsCount
backedProjects(first: $first, after: $after) {
nodes {
__typename
nodes {
__typename
...ProjectFragment
}
pageInfo {
__typename
hasNextPage
endCursor
hasPreviousPage
startCursor
}
...ProjectFragment
}
pageInfo {
__typename
hasNextPage
endCursor
hasPreviousPage
startCursor
}
totalCount
}
}
"""
Expand Down Expand Up @@ -8481,7 +8478,7 @@ public enum GraphAPI {

public static var selections: [GraphQLSelection] {
return [
GraphQLField("me", type: .object(Me.selections)),
GraphQLField("projects", arguments: ["first": GraphQLVariable("first"), "after": GraphQLVariable("after"), "backed": true, "sort": "END_DATE"], type: .object(Project.selections)),
]
}

Expand All @@ -8491,28 +8488,29 @@ public enum GraphAPI {
self.resultMap = unsafeResultMap
}

public init(me: Me? = nil) {
self.init(unsafeResultMap: ["__typename": "Query", "me": me.flatMap { (value: Me) -> ResultMap in value.resultMap }])
public init(projects: Project? = nil) {
self.init(unsafeResultMap: ["__typename": "Query", "projects": projects.flatMap { (value: Project) -> ResultMap in value.resultMap }])
}

/// You.
public var me: Me? {
/// Get some projects
public var projects: Project? {
get {
return (resultMap["me"] as? ResultMap).flatMap { Me(unsafeResultMap: $0) }
return (resultMap["projects"] as? ResultMap).flatMap { Project(unsafeResultMap: $0) }
}
set {
resultMap.updateValue(newValue?.resultMap, forKey: "me")
resultMap.updateValue(newValue?.resultMap, forKey: "projects")
}
}

public struct Me: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["User"]
public struct Project: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["ProjectsConnectionWithTotalCount"]

public static var selections: [GraphQLSelection] {
return [
GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
GraphQLField("backingsCount", type: .nonNull(.scalar(Int.self))),
GraphQLField("backedProjects", arguments: ["first": GraphQLVariable("first"), "after": GraphQLVariable("after")], type: .object(BackedProject.selections)),
GraphQLField("nodes", type: .list(.object(Node.selections))),
GraphQLField("pageInfo", type: .nonNull(.object(PageInfo.selections))),
GraphQLField("totalCount", type: .nonNull(.scalar(Int.self))),
]
}

Expand All @@ -8522,8 +8520,8 @@ public enum GraphAPI {
self.resultMap = unsafeResultMap
}

public init(backingsCount: Int, backedProjects: BackedProject? = nil) {
self.init(unsafeResultMap: ["__typename": "User", "backingsCount": backingsCount, "backedProjects": backedProjects.flatMap { (value: BackedProject) -> ResultMap in value.resultMap }])
public init(nodes: [Node?]? = nil, pageInfo: PageInfo, totalCount: Int) {
self.init(unsafeResultMap: ["__typename": "ProjectsConnectionWithTotalCount", "nodes": nodes.flatMap { (value: [Node?]) -> [ResultMap?] in value.map { (value: Node?) -> ResultMap? in value.flatMap { (value: Node) -> ResultMap in value.resultMap } } }, "pageInfo": pageInfo.resultMap, "totalCount": totalCount])
}

public var __typename: String {
Expand All @@ -8535,34 +8533,42 @@ public enum GraphAPI {
}
}

/// Number of backings for this user.
public var backingsCount: Int {
/// A list of nodes.
public var nodes: [Node?]? {
get {
return resultMap["backingsCount"]! as! Int
return (resultMap["nodes"] as? [ResultMap?]).flatMap { (value: [ResultMap?]) -> [Node?] in value.map { (value: ResultMap?) -> Node? in value.flatMap { (value: ResultMap) -> Node in Node(unsafeResultMap: value) } } }
}
set {
resultMap.updateValue(newValue, forKey: "backingsCount")
resultMap.updateValue(newValue.flatMap { (value: [Node?]) -> [ResultMap?] in value.map { (value: Node?) -> ResultMap? in value.flatMap { (value: Node) -> ResultMap in value.resultMap } } }, forKey: "nodes")
}
}

/// Projects a user has backed.
public var backedProjects: BackedProject? {
/// Information to aid in pagination.
public var pageInfo: PageInfo {
get {
return (resultMap["backedProjects"] as? ResultMap).flatMap { BackedProject(unsafeResultMap: $0) }
return PageInfo(unsafeResultMap: resultMap["pageInfo"]! as! ResultMap)
}
set {
resultMap.updateValue(newValue?.resultMap, forKey: "backedProjects")
resultMap.updateValue(newValue.resultMap, forKey: "pageInfo")
}
}

public struct BackedProject: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["UserBackedProjectsConnection"]
public var totalCount: Int {
get {
return resultMap["totalCount"]! as! Int
}
set {
resultMap.updateValue(newValue, forKey: "totalCount")
}
}

public struct Node: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["Project"]

public static var selections: [GraphQLSelection] {
return [
GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
GraphQLField("nodes", type: .list(.object(Node.selections))),
GraphQLField("pageInfo", type: .nonNull(.object(PageInfo.selections))),
GraphQLFragmentSpread(ProjectFragment.self),
]
}

Expand All @@ -8572,10 +8578,6 @@ public enum GraphAPI {
self.resultMap = unsafeResultMap
}

public init(nodes: [Node?]? = nil, pageInfo: PageInfo) {
self.init(unsafeResultMap: ["__typename": "UserBackedProjectsConnection", "nodes": nodes.flatMap { (value: [Node?]) -> [ResultMap?] in value.map { (value: Node?) -> ResultMap? in value.flatMap { (value: Node) -> ResultMap in value.resultMap } } }, "pageInfo": pageInfo.resultMap])
}

public var __typename: String {
get {
return resultMap["__typename"]! as! String
Expand All @@ -8585,148 +8587,102 @@ public enum GraphAPI {
}
}

/// A list of nodes.
public var nodes: [Node?]? {
get {
return (resultMap["nodes"] as? [ResultMap?]).flatMap { (value: [ResultMap?]) -> [Node?] in value.map { (value: ResultMap?) -> Node? in value.flatMap { (value: ResultMap) -> Node in Node(unsafeResultMap: value) } } }
}
set {
resultMap.updateValue(newValue.flatMap { (value: [Node?]) -> [ResultMap?] in value.map { (value: Node?) -> ResultMap? in value.flatMap { (value: Node) -> ResultMap in value.resultMap } } }, forKey: "nodes")
}
}

/// Information to aid in pagination.
public var pageInfo: PageInfo {
public var fragments: Fragments {
get {
return PageInfo(unsafeResultMap: resultMap["pageInfo"]! as! ResultMap)
return Fragments(unsafeResultMap: resultMap)
}
set {
resultMap.updateValue(newValue.resultMap, forKey: "pageInfo")
resultMap += newValue.resultMap
}
}

public struct Node: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["Project"]

public static var selections: [GraphQLSelection] {
return [
GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
GraphQLFragmentSpread(ProjectFragment.self),
]
}

public struct Fragments {
public private(set) var resultMap: ResultMap

public init(unsafeResultMap: ResultMap) {
self.resultMap = unsafeResultMap
}

public var __typename: String {
get {
return resultMap["__typename"]! as! String
}
set {
resultMap.updateValue(newValue, forKey: "__typename")
}
}

public var fragments: Fragments {
public var projectFragment: ProjectFragment {
get {
return Fragments(unsafeResultMap: resultMap)
return ProjectFragment(unsafeResultMap: resultMap)
}
set {
resultMap += newValue.resultMap
}
}
}
}

public struct Fragments {
public private(set) var resultMap: ResultMap

public init(unsafeResultMap: ResultMap) {
self.resultMap = unsafeResultMap
}
public struct PageInfo: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["PageInfo"]

public var projectFragment: ProjectFragment {
get {
return ProjectFragment(unsafeResultMap: resultMap)
}
set {
resultMap += newValue.resultMap
}
}
}
public static var selections: [GraphQLSelection] {
return [
GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
GraphQLField("hasNextPage", type: .nonNull(.scalar(Bool.self))),
GraphQLField("endCursor", type: .scalar(String.self)),
GraphQLField("hasPreviousPage", type: .nonNull(.scalar(Bool.self))),
GraphQLField("startCursor", type: .scalar(String.self)),
]
}

public struct PageInfo: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["PageInfo"]
public private(set) var resultMap: ResultMap

public static var selections: [GraphQLSelection] {
return [
GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
GraphQLField("hasNextPage", type: .nonNull(.scalar(Bool.self))),
GraphQLField("endCursor", type: .scalar(String.self)),
GraphQLField("hasPreviousPage", type: .nonNull(.scalar(Bool.self))),
GraphQLField("startCursor", type: .scalar(String.self)),
]
}
public init(unsafeResultMap: ResultMap) {
self.resultMap = unsafeResultMap
}

public private(set) var resultMap: ResultMap
public init(hasNextPage: Bool, endCursor: String? = nil, hasPreviousPage: Bool, startCursor: String? = nil) {
self.init(unsafeResultMap: ["__typename": "PageInfo", "hasNextPage": hasNextPage, "endCursor": endCursor, "hasPreviousPage": hasPreviousPage, "startCursor": startCursor])
}

public init(unsafeResultMap: ResultMap) {
self.resultMap = unsafeResultMap
public var __typename: String {
get {
return resultMap["__typename"]! as! String
}

public init(hasNextPage: Bool, endCursor: String? = nil, hasPreviousPage: Bool, startCursor: String? = nil) {
self.init(unsafeResultMap: ["__typename": "PageInfo", "hasNextPage": hasNextPage, "endCursor": endCursor, "hasPreviousPage": hasPreviousPage, "startCursor": startCursor])
set {
resultMap.updateValue(newValue, forKey: "__typename")
}
}

public var __typename: String {
get {
return resultMap["__typename"]! as! String
}
set {
resultMap.updateValue(newValue, forKey: "__typename")
}
/// When paginating forwards, are there more items?
public var hasNextPage: Bool {
get {
return resultMap["hasNextPage"]! as! Bool
}

/// When paginating forwards, are there more items?
public var hasNextPage: Bool {
get {
return resultMap["hasNextPage"]! as! Bool
}
set {
resultMap.updateValue(newValue, forKey: "hasNextPage")
}
set {
resultMap.updateValue(newValue, forKey: "hasNextPage")
}
}

/// When paginating forwards, the cursor to continue.
public var endCursor: String? {
get {
return resultMap["endCursor"] as? String
}
set {
resultMap.updateValue(newValue, forKey: "endCursor")
}
/// When paginating forwards, the cursor to continue.
public var endCursor: String? {
get {
return resultMap["endCursor"] as? String
}
set {
resultMap.updateValue(newValue, forKey: "endCursor")
}
}

/// When paginating backwards, are there more items?
public var hasPreviousPage: Bool {
get {
return resultMap["hasPreviousPage"]! as! Bool
}
set {
resultMap.updateValue(newValue, forKey: "hasPreviousPage")
}
/// When paginating backwards, are there more items?
public var hasPreviousPage: Bool {
get {
return resultMap["hasPreviousPage"]! as! Bool
}
set {
resultMap.updateValue(newValue, forKey: "hasPreviousPage")
}
}

/// When paginating backwards, the cursor to continue.
public var startCursor: String? {
get {
return resultMap["startCursor"] as? String
}
set {
resultMap.updateValue(newValue, forKey: "startCursor")
}
/// When paginating backwards, the cursor to continue.
public var startCursor: String? {
get {
return resultMap["startCursor"] as? String
}
set {
resultMap.updateValue(newValue, forKey: "startCursor")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ReactiveSwift
extension FetchProjectsEnvelope {
static func fetchProjectsEnvelope(from data: GraphAPI.FetchMyBackedProjectsQuery.Data)
-> SignalProducer<FetchProjectsEnvelope, ErrorEnvelope> {
guard let projects = data.me?.backedProjects?.nodes?.compactMap({ node -> Project? in
guard let projects = data.projects?.nodes?.compactMap({ node -> Project? in
if let fragment = node?.fragments.projectFragment {
return Project.project(from: fragment, currentUserChosenCurrency: nil)
}
Expand All @@ -16,9 +16,9 @@ extension FetchProjectsEnvelope {
let envelope = FetchProjectsEnvelope(
type: .backed,
projects: projects,
cursor: data.me?.backedProjects?.pageInfo.endCursor,
hasNextPage: data.me?.backedProjects?.pageInfo.hasNextPage ?? false,
totalCount: data.me?.backingsCount ?? 0
cursor: data.projects?.pageInfo.endCursor,
hasNextPage: data.projects?.pageInfo.hasNextPage ?? false,
totalCount: data.projects?.totalCount ?? 0
)

return SignalProducer(value: envelope)
Expand Down
Loading