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

[Feature] Implementation of the public discord statuspage api #55

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

Almighty-Alpaca
Copy link
Member

@Almighty-Alpaca Almighty-Alpaca commented Feb 15, 2018

which can be found here. This currently does not include the uptime tracker or incident history (more than last 50 incidents) as they are not part of the public api. Probably also still needs a bit more documentation.

@Almighty-Alpaca Almighty-Alpaca added the Enhancement Modification of existing code-base to enhance quality and/or functionality. label Feb 15, 2018
@Almighty-Alpaca Almighty-Alpaca self-assigned this Feb 15, 2018
Copy link
Collaborator

@Shengaero Shengaero left a comment

Choose a reason for hiding this comment

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

This PR needs work.
I saw no documentation, very inconsistent code-style, improper and overuse of the javax.annotation API, and other things that preclude it from being merged.

@Nonnull
protected static final String URL_SCHEDULED_MAINTENANCES_ACTIVE = URL_API_BASE + "scheduled-maintenances/active.json";
@Nonnull
protected static final String URL_SCHEDULED_MAINTENANCES_UPCOMING = URL_API_BASE + "scheduled-maintenances/upcoming.json";
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the scheduled-maintenances endpoints and organization's sake, we should have a base url

    @Nonnull
    protected static final String URL_SCHEDULED_MAINTENANCES_BASE = URL_API_BASE + "scheduled-maintenances";
    @Nonnull
    protected static final String URL_SCHEDULED_MAINTENANCES_ALL = URL_SCHEDULED_MAINTENANCES_BASE + ".json";
    @Nonnull
    protected static final String URL_SCHEDULED_MAINTENANCES_ACTIVE = URL_SCHEDULED_MAINTENANCES_BASE + "/active.json";
    @Nonnull
    protected static final String URL_SCHEDULED_MAINTENANCES_UPCOMING = URL_SCHEDULED_MAINTENANCES_BASE + "/upcoming.json";

The same might be worth doing for incidents although I'll leave that up to you.

@Nonnull
final JSONObject statusObject = object.getJSONObject("status");
@Nonnull
final Status status = createStatus(statusObject);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see a reason to have @Nonnull, @Nullable, and similar kinds of annotations in method bodies.
I won't make you remove any of the method, class, and field annotations, but I would be hesitant on adding nullable annotations in the future as I have been considering adding them to the library myself, but only if and when feature/nullability is merged.

@Nonnull
final Page page = createPage(pageObject);

return new Incidents(page, incidents);
Copy link
Collaborator

Choose a reason for hiding this comment

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

See my comment on @Nonnull and @Nullable in method bodies

@Nonnull
final List<ScheduledMaintenance> scheduledMaintenances = new ArrayList<>(scheduledMaintenancesArray.length());
for (int i = 0; i < scheduledMaintenancesArray.length(); i++)
scheduledMaintenances.add(createScheduledMaintenance(scheduledMaintenancesArray.getJSONObject(i)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

See my comment on @Nonnull and @Nullable in method bodies

@Nonnull
final JSONObject statusObject = object.getJSONObject("status");
@Nonnull
final Status status = createStatus(statusObject);
Copy link
Collaborator

Choose a reason for hiding this comment

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

See my comment on @Nonnull and @Nullable in method bodies


@Override
@Nonnull
public List<Incident> subList(int fromIndex, int toIndex) {return incidents.subList(fromIndex, toIndex);}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This formatting seems fairly... odd?


@Override
@Nonnull
public List<ScheduledMaintenance> subList(int fromIndex, int toIndex) {return ScheduledMaintenances.subList(fromIndex, toIndex);}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This formatting seems fairly... odd?

@Nonnull
protected final Page page;
@Nonnull
protected final List<ScheduledMaintenance> ScheduledMaintenances;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this formatting...?

Copy link
Member Author

Choose a reason for hiding this comment

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

I used a json2pojo generator, probably just didn't saw what it has done here.

public <T> T[] toArray(@Nonnull T[] a) {return ScheduledMaintenances.toArray(a);}

@Override
public boolean add(ScheduledMaintenance ScheduledMaintenance) {return ScheduledMaintenances.add(ScheduledMaintenance);}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This class is marked as @Immutable yet we are allowing modification of the underlying list?
This should throw UnsupportedOperationException or the List interface should not be implemented at all.
(This goes for all other methods that might modify this object)

{
statuspage.getSummary().get();
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we remove this test class?

Copy link
Member Author

Choose a reason for hiding this comment

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

What is wrong with tests?

@Shengaero
Copy link
Collaborator

This would also be a good time to mention that changes to our build setup should be made to allow certain modules to not be included in the collective dependency (IE: com.jagrosh:jda-utilities:VERSION) because this module is not something most people who compile the collective dependency for their bots would even use.

@Shengaero Shengaero added Proposal Proposal for a new feature, enhancement, or changes. Version: 2.2 Feature A new and full feature implementation. and removed Version: 2.2 Enhancement Modification of existing code-base to enhance quality and/or functionality. labels Feb 21, 2018
and implemented this for the statuspage module.
- Fixed immutable classes
- Removed nullability annotation abuse
- Removed List interface from classes as yo ucan get the list via a method
@Shengaero Shengaero changed the title Implementation of the public discord statuspage api [Feature] Implementation of the public discord statuspage api Apr 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A new and full feature implementation. Proposal Proposal for a new feature, enhancement, or changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants