-
Notifications
You must be signed in to change notification settings - Fork 5
/
ISIssue.j
58 lines (51 loc) · 2.14 KB
/
ISIssue.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@implementation ISIssue : CPObject
{
CPString pullRequest @accessors;
CPDate closedAt @accessors;
ISMilestone milestone @accessors;
CPString body @accessors;
CPArray comments @accessors;
unsigned numberOfComments @accessors;
CPString url @accessors;
CPDate updatedAt @accessors;
CPDate createdAt @accessors;
CPDictionary assignee @accessors;
CPString state @accessors;
CPString title @accessors;
unsigned number @accessors;
CPDictionary user @accessors;
CPArray labels @accessors;
}
/*!
Utility method. The predicate returned should not be reused if the logged in user changes.
*/
+ (CPPredicate)issueAssignedToCurrentUserPredicate
{
var loggedInUser = [[ISGithubAPIController sharedController] username];
if (!loggedInUser)
return nil;
return [CPPredicate predicateWithFormat:@"(assignee.login == %@)", loggedInUser];
}
+ (id)issuesWithJSObject:(JSObject)anObject
{
newIssues = [ISIssue new];
newIssues.pullRequest = anObject.pullRequest || "";
newIssues.closedAt = [CPDate dateFromISO8601:anObject.closed_at] || nil;
newIssues.milestone = anObject.milestone;
newIssues.body = anObject.body || "";
newIssues.numberOfComments = anObject.comments || 0;
newIssues.comments = []; //JSObject wont' have comments initially.
newIssues.url = anObject.URL || "";
newIssues.updatedAt = [CPDate dateFromISO8601:anObject.updated_at] || nil;
newIssues.createdAt = [CPDate dateFromISO8601:anObject.create_at] || nil;
newIssues.assignee = [CPDictionary dictionaryWithJSObject:anObject.assignee recursively:YES];
newIssues.state = anObject.state || "closed";
newIssues.title = anObject.title || "";
newIssues.number = anObject.number || CPNotFound; // maybe nil?
newIssues.user = [CPDictionary dictionaryWithJSObject:anObject.user recursively:YES];
newIssues.labels = [];
for (var i = 0, c = anObject.labels.length; i < c; i++)
newIssues.labels.push([ISLabel labelWithJSObject:anObject.labels[i]]);
return newIssues;
}
@end