-
Notifications
You must be signed in to change notification settings - Fork 435
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
Milestones module development #343
base: master
Are you sure you want to change the base?
Changes from 104 commits
081cf03
ae5596c
2d6fe3f
2c8f445
56e2ae2
970e2d0
f7ba846
e2a05c3
0f89372
1d4b946
3c2e2f3
97ef560
177aff9
f789379
fcff329
61d168e
fe86c30
095bbf9
be4ea89
e98304c
a49d793
25634e3
46b674a
7f9bcc3
98123ee
3e97b5c
cd188da
bc378c7
2fe6404
6e2c675
0bddafe
ce9fb35
ee9cd86
01ed3cc
59a4f43
233d72c
c3b3504
620200e
d1137ac
f19b59f
255aef7
9df359c
ff7665e
19429a6
db30f03
7affe5d
d8d5aaf
5a29dc2
6fa48a4
80c2d1a
411a16b
ff8356f
cc7da89
6d3f519
548d9fd
5377028
2757d25
b45e03c
c73bfad
f2e7240
45e45df
1f78dbd
4f5ff22
fdfe8f5
d03ed67
5f549cc
8c0ed93
2bcf70e
aaeb72d
4719e9e
33e9980
c21e65b
9a3f483
f3928f2
af5a5a0
8e2b5db
7043b70
135d903
9aeb8a2
a8fecea
25824b6
0f80cc2
b39189c
25bd40d
90b08e0
6073cbc
f8a2b01
fb43465
ae70857
02863ad
69ccc84
ed44be6
d61237d
cf31ab7
e860b82
c57c96b
fd6a50a
e518b7c
e4602e6
baa1bd8
4cc54a6
00d3e2b
cd41a4a
6e47980
bf37592
ab0329d
c4d3159
4b87e74
e3a85c2
9e5ae56
30048f0
0883b55
f493fe9
d3658ad
19d4db3
f2044a2
42f616c
d2b391c
68a24e6
f60a50e
4b38c89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import com.github.mobile.accounts.GitHubAccount; | ||
import com.github.mobile.api.DateAdapter; | ||
import com.github.mobile.api.RequestConfiguration; | ||
import com.github.mobile.api.model.Milestone; | ||
import com.github.mobile.core.commit.CommitStore; | ||
import com.github.mobile.core.gist.GistStore; | ||
import com.github.mobile.core.issue.IssueStore; | ||
|
@@ -33,6 +34,7 @@ | |
import com.google.inject.Singleton; | ||
import com.google.inject.assistedinject.FactoryModuleBuilder; | ||
import com.google.inject.name.Named; | ||
import com.squareup.moshi.JsonAdapter; | ||
import com.squareup.moshi.Moshi; | ||
|
||
import java.io.File; | ||
|
@@ -80,8 +82,11 @@ Retrofit retrofit(Provider<GitHubAccount> accountProvider) { | |
.addInterceptor(new RequestConfiguration(accountProvider)) | ||
.build(); | ||
|
||
JsonAdapter<Milestone> adapter = | ||
new Moshi.Builder().add(new DateAdapter()).build().adapter(Milestone.class).serializeNulls(); | ||
Moshi converter = new Moshi.Builder() | ||
.add(new DateAdapter()) | ||
.add(Milestone.class, adapter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need a custom adapter for milestones? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To allow setting null due_date for milestone There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't you achieve the same result by modifying the current There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, default adapter for milestones just ignores null properties. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I mean changing the behavior of https://github.com/jonan/ForkHub/blob/master/app/src/main/java/com/github/mobile/api/DateAdapter.java which is already being used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we set due_on = null, then DateAdapter is not being called by Milestone adapter because it skips null properties. |
||
.build(); | ||
|
||
return new Retrofit.Builder() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,11 @@ | |
*/ | ||
package com.github.mobile.api.model; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
public class Issue { | ||
public class Issue implements Serializable { | ||
public long id; | ||
|
||
public Repository repository; | ||
|
@@ -76,6 +77,10 @@ public org.eclipse.egit.github.core.Issue getOldModel() { | |
issue.setCreatedAt(created_at); | ||
issue.setClosedAt(closed_at); | ||
issue.setUpdatedAt(updated_at); | ||
if (milestone != null){ | ||
issue.setMilestone(milestone.getOldModel()); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespace missing before There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in phansier@30048f0 |
||
if (user != null) { | ||
issue.setUser(user.getOldModel()); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,11 @@ | |
*/ | ||
package com.github.mobile.api.model; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
public class Milestone { | ||
public class Milestone implements Serializable { | ||
public static final String MS_STATE_OPEN = "open"; | ||
public long id; | ||
|
||
public int number; | ||
|
@@ -41,4 +43,45 @@ public class Milestone { | |
public Date closed_at; | ||
|
||
public Date due_on; | ||
|
||
private String url; | ||
|
||
public Milestone() { | ||
state = MS_STATE_OPEN; | ||
} | ||
|
||
public Milestone(org.eclipse.egit.github.core.Milestone milestone) { | ||
//todo this.id=? | ||
//there are two variants of id usage | ||
//1)id is like an id in Issues, but it is in old Issues class too - the remove field | ||
//2)id is like an serialVersionUID - then generate it using "serialver -classpath . Milestone" in terminal | ||
this.number = milestone.getNumber(); | ||
this.state = milestone.getState(); | ||
this.title = milestone.getTitle(); | ||
this.description = milestone.getDescription(); | ||
org.eclipse.egit.github.core.User creator = milestone.getCreator(); | ||
this.creator = creator == null ? null : new User(creator); | ||
this.open_issues = milestone.getOpenIssues(); | ||
this.closed_issues = milestone.getClosedIssues(); | ||
this.created_at = milestone.getCreatedAt(); | ||
this.url = milestone.getUrl(); | ||
//todo this.updated_at=??? | ||
this.due_on = milestone.getDueOn(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you adding this comments here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an issue of probably missing some information in transition from old Milestone model to new one. |
||
|
||
public org.eclipse.egit.github.core.Milestone getOldModel() { | ||
org.eclipse.egit.github.core.Milestone milestone = new org.eclipse.egit.github.core.Milestone(); | ||
milestone.setCreatedAt(created_at); | ||
milestone.setDueOn(due_on); | ||
milestone.setClosedIssues(closed_issues); | ||
milestone.setNumber(number); | ||
milestone.setOpenIssues(open_issues); | ||
milestone.setDescription(description); | ||
milestone.setState(state); | ||
milestone.setTitle(title); | ||
milestone.setUrl(url); | ||
milestone.setCreator(creator.getOldModel()); | ||
|
||
return milestone; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,13 @@ Call<Issue> getIssue( | |
@Path("repo") String repo, | ||
@Path("number") long number); | ||
|
||
@Headers("Accept: application/vnd.github.squirrel-girl-preview") | ||
@GET("repos/{owner}/{repo}/issues") | ||
Call<List<Issue>> getIssues( | ||
@Path("owner") String owner, | ||
@Path("repo") String repo, | ||
@Query("milestone") String milestone); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This request doesn't work with pagination (we can fix it in a future commit if you prefer) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We prefer to fix it in future because it is not the vital problem for milestones |
||
@Headers({"Accept: application/vnd.github.v3.full+json", | ||
"Accept: application/vnd.github.mockingbird-preview", | ||
"Accept: application/vnd.github.squirrel-girl-preview"}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright 2016 Jon Ander Peñalba | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.github.mobile.api.service; | ||
|
||
import com.github.mobile.api.model.Issue; | ||
import com.github.mobile.api.model.Milestone; | ||
import java.util.List; | ||
|
||
import retrofit2.Call; | ||
import retrofit2.http.Body; | ||
import retrofit2.http.DELETE; | ||
import retrofit2.http.GET; | ||
import retrofit2.http.Headers; | ||
import retrofit2.http.PATCH; | ||
import retrofit2.http.POST; | ||
import retrofit2.http.Path; | ||
import retrofit2.http.Query; | ||
|
||
public interface MilestoneService { | ||
@Headers("Accept: application/vnd.github.v3+json") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This header is not needed, as we add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tsnik Please take a look, whether we could remove these? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in phansier@f2044a2 |
||
@GET("repos/{owner}/{repo}/milestones/{number}") | ||
Call<Milestone> getMilestone( | ||
@Path("owner") String owner, | ||
@Path("repo") String repo, | ||
@Path("number") long number); | ||
|
||
@Headers("Accept: application/vnd.github.v3+json") | ||
@GET("repos/{owner}/{repo}/milestones") | ||
Call<List<Milestone>> getMilestones( | ||
@Path("owner") String owner, | ||
@Path("repo") String repo); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pagination not working again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We prefer to fix it in future because it is not the vital problem for milestones |
||
|
||
@Headers("Accept: application/vnd.github.squirrel-girl-preview") | ||
@GET("repos/{owner}/{repo}/issues") | ||
Call<List<Issue>> getIssues( | ||
@Path("owner") String owner, | ||
@Path("repo") String repo, | ||
@Query("milestone") long milestone); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More pagination problems. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We prefer to fix it in future because it is not the vital problem for milestones |
||
|
||
@Headers("Accept: application/vnd.github.v3+json") | ||
@POST("repos/{owner}/{repo}/milestones") | ||
Call<Milestone> createMilestone ( | ||
@Path("owner") String owner, | ||
@Path("repo") String repo, | ||
@Body Milestone milestone); | ||
|
||
@Headers("Accept: application/vnd.github.v3+json") | ||
@PATCH("repos/{owner}/{repo}/milestones/{number}") | ||
Call<Milestone> editMilestone ( | ||
@Path("owner") String owner, | ||
@Path("repo") String repo, | ||
@Path("number") long number, | ||
@Body Milestone milestone); | ||
|
||
@Headers("Accept: application/vnd.github.v3+json") | ||
@DELETE("repos/{owner}/{repo}/milestones/{number}") | ||
Call<Milestone> deleteMilestone( | ||
@Path("owner") String owner, | ||
@Path("repo") String repo, | ||
@Path("number") long number); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be done removing the old
org.eclipse.egit.github.core.Milestone
code, simply creating the milestone with the new model object.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in phansier@9e5ae56
If OK, will be merged to PR