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

Fetch current user's issues & a specific repository's issues #28

Merged
merged 48 commits into from
Jul 20, 2016

Conversation

Palleas
Copy link
Collaborator

@Palleas Palleas commented May 24, 2016

Hello !

It's a WIP, but I figured I should open a PR just in case somebody is working on this too 😉

I'll update this soon!


public let locked: Bool
public let comments: Int
public let pullRequest: PullRequest?

Choose a reason for hiding this comment

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

Identation

@Palleas
Copy link
Collaborator Author

Palleas commented May 25, 2016

Slowly getting there, I'm having a hard time wrapping my head around Argo 😁

@mdiep
Copy link
Owner

mdiep commented May 26, 2016

Slowly getting there, I'm having a hard time wrapping my head around Argo 😁

Let me know if you need any help!

@Palleas
Copy link
Collaborator Author

Palleas commented May 26, 2016

Let me know if you need any help!

I think I do! I'll push my work (I've added a couple of new things, like an actually passing test) and maybe we can take things from here, I'm having a hard time with mapping some dates (updated/created and closed because the last one is nil)

Beside that I think it should be ready quickly because most of the work was already there. :)

// <*> j <| "milestone"
<*> j <| "locked"
<*> j <| "comments"
// <*> (j <|? "closed_at" >>- toNSDate)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mdiep do you see something wrong with this ? Somehow it fails at mapping the date, saying the keys closed_at, updated_at and created at don't exist when they do (but the closed_at is null).

I've updated the decode() method temporarily to print the error when mapping fails)

Copy link
Owner

Choose a reason for hiding this comment

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

When I run the test you added with the fixture data, the createdAt and updatedAt fields are correctly decoded. 😕

(Sorry I didn't look at this sooner!)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah it seems to be working, but it fails because of a "MissingKey" error, see the log:

Returning date: 2016-05-24 23:38:39 +0000
Returning date: 2016-05-24 23:38:39 +0000
decoded = Failure(MissingKey(created_at))

Am I missing something?

Copy link
Collaborator Author

@Palleas Palleas Jun 7, 2016

Choose a reason for hiding this comment

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

Oooooh, I think the created_at error does not come from the Issue but probably something else!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When I remove the mapping User part by commenting out the user argument, it works. Could this be a bug in Argo..? I read the relationship were supposed to be working auto-magically... 😁

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah! That makes it easier to review and discuss. 😄

Copy link
Owner

Choose a reason for hiding this comment

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

Are you still interested in pursuing this?

Copy link
Collaborator Author

@Palleas Palleas Jul 4, 2016

Choose a reason for hiding this comment

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

I just come back from vacations, sorry I should have warned you. I'm still interested in working on this, but if you think you can tackle the user refactoring part relatively soon, it'll probably be better since I'm finding my ways in Tentacle. 😄

Copy link
Owner

Choose a reason for hiding this comment

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

This sounded like a nice break from reviewing PRs, so I did it tonight: #31. 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cool! I'll rebase my branch and keep working on this this week! Thanks 😋

@Palleas
Copy link
Collaborator Author

Palleas commented Jul 8, 2016

screen shot 2016-07-08 at 3 16 23 pm

atrapitis

I'll dig a little more during the week-end but I'm slowly getting there. 😄

@Palleas
Copy link
Collaborator Author

Palleas commented Jul 9, 2016

@mdiep I'm sorry but I have one more issue with Argo / Curry. In the current Issue I'm using in my test, the "closed_at" is null, which means the tests fail with MissingKey(closed_at). The test passes when I set a valid date for the closed_at key in the payload.
Is this because the toNSDate function doesn't accept an optional String? I've tried using <|? instead of just <| but it doesn't work.

Otherwise I've started using Tentacle to fetch Issues in my app and it works well 👌

@Palleas Palleas changed the title [WIP] Add method to fetch current user's issues Add method to fetch current user's issues Jul 14, 2016
@Palleas Palleas changed the title Add method to fetch current user's issues Fetch current user's issues & a specific repository's issues Jul 14, 2016
@Palleas
Copy link
Collaborator Author

Palleas commented Jul 14, 2016

@mdiep I just added support for Milestone and PullRequest so I think this is ready for a deeper code review. Let me know if you want me to squash my branch first!

7A1A82551CF3DBAC0076E2DD /* Issue.swift */,
7A1A82571CF3DE4C0076E2DD /* Label.swift */,
7A1A82591CF3DEEA0076E2DD /* Milestone.swift */,
7A1A825D1CF3E5B60076E2DD /* PullRequest.swift */,
Copy link
Owner

Choose a reason for hiding this comment

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

Could you alphabetize the new files in the Xcode project navigator? 🙏

public let id: Int

/// The URL to view this issue in a browser
public let url: NSURL?
Copy link
Owner

Choose a reason for hiding this comment

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

This should be URL.

@mdiep
Copy link
Owner

mdiep commented Jul 18, 2016

For the label colors, I've simply copied the code from SwiftHEXcolors (keeping the license ofc) because it seemed a bit overkill to add it as a Carthage dependency and a bit useless to write my own poorer implementation of Hex color parsing. Please let me know what you think.

I'm not wild about doing that. Let me think about it.

@Palleas
Copy link
Collaborator Author

Palleas commented Jul 18, 2016

I'm not wild about doing that. Let me think about it.

Sure, let me know 😄

&& lhs.updatedAt == rhs.updatedAt
&& lhs.labels == rhs.labels
&& lhs.milestone == rhs.milestone
&& lhs.pullRequest == rhs.pullRequest
Copy link
Owner

Choose a reason for hiding this comment

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

Indentation is off here. && lines should be indented another level.

@mdiep
Copy link
Owner

mdiep commented Jul 19, 2016

Here's a Color initializer that we can use:

import AppKit

typealias Color = NSColor

extension Color {
    convenience init(hex: String) {
        precondition(hex.characters.count == 6)

        let scanner = NSScanner(string: hex)
        var rgb: UInt32 = 0
        scanner.scanHexInt(&rgb)

        let r = CGFloat((rgb & 0xff0000) >> 16) / 255.0
        let g = CGFloat((rgb & 0x00ff00) >>  8) / 255.0
        let b = CGFloat((rgb & 0x0000ff) >>  0) / 255.0
        self.init(red: r, green: g, blue: b, alpha: 1)
    }
}

(You'll need to add some #ifs to make it work on iOS too.)

Would you mind adding some tests for it? These cases should be a decent start:

Color(hex: "ffffff")
Color(hex: "aa0000")
Color(hex: "00aa00")
Color(hex: "0000aa")
Color(hex: "000000")

@Palleas
Copy link
Collaborator Author

Palleas commented Jul 19, 2016

Done, done, done and done. Slowly getting there!

@mdiep
Copy link
Owner

mdiep commented Jul 20, 2016

This is great! Thank you for all the work you put in on this! ⚡ ⚡ ⚡

@mdiep mdiep merged commit 1b5b018 into mdiep:master Jul 20, 2016
@Palleas Palleas deleted the user-issues branch July 20, 2016 01:30
@Palleas
Copy link
Collaborator Author

Palleas commented Jul 20, 2016

Wouhou, cool! 🎉

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.

3 participants