Skip to content
This repository was archived by the owner on Oct 29, 2019. It is now read-only.

Conversation

@zmike808
Copy link
Contributor

@zmike808 zmike808 commented Nov 2, 2016

Implemented feature #455. Only issue left is solving an async issue with the DB disconnecting before the commits finish saving. Besides that, everything is working. So, I'd like to get my code reviewed and hopefully merged in.

@zmike808 zmike808 changed the title Feature/455 Feature/455 (Github pull integration #455) Nov 2, 2016
@kmcnellis
Copy link
Member

Could you give a description of how everything works?

@kmcnellis kmcnellis closed this Nov 8, 2016
@kmcnellis kmcnellis reopened this Nov 8, 2016
Copy link
Member

@kmcnellis kmcnellis left a comment

Choose a reason for hiding this comment

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

Good progress so far

function (projects) {
projects.forEach(
function (project) {
console.error("PROJECT: ", project.fullRepoPath);
Copy link
Member

Choose a reason for hiding this comment

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

Remove console.log

function (commitData) {
var newCommit = new Commit(commitData);

// super hacky, definitely need to abstract this before github's api changes and this goes boom!!
Copy link
Member

Choose a reason for hiding this comment

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

Is there any way to record the author or prevent loading the same commit twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The author field of the Commit model is currently populated & saved. As for preventing the loading of the same commit, do you mean when scraping Github, or actually running a save to the DB?

Copy link
Member

Choose a reason for hiding this comment

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

For saving to the db. Like if it has the same hash as one we already saved, update the data instead of adding a second copy. Although, it might also be good to save the last updated date and ignore everything before it in the github query.

function (projects) {
projects.forEach(
function (project) {
console.error("PROJECT: ", project.fullRepoPath);
Copy link
Member

Choose a reason for hiding this comment

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

What happens if the project url is invalid?

).then(
function () {
// @TODO FIX ASYNC ISSUES SO DISCONNECT HAPPENS AFTER ALL SAVES HAVE COMPLETED.
// Spent like 4 hours trying to debug this, but javascript is just too magical and asynchronous for me =(
Copy link
Member

Choose a reason for hiding this comment

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

Comments like these are best for the issue or PR, so that people can discuss them. What have you tried?

@kmcnellis
Copy link
Member

How often would this be run? Is there any way for an admin to run a batch?

var octoclient = octo.client(token);

Project.find().exec().then(
function (projects) {
Copy link
Member

Choose a reason for hiding this comment

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

It would be better if this was modular and could be run on only a specific set of projects

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good point. Right now it's running on all projects, which definitely wouldn't be ideal behavior in the production env.
Also, thanks for taking the time to look over my PR. I'll start working on these changes as soon as I can.

Copy link
Member

Choose a reason for hiding this comment

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

👍

@zmike808
Copy link
Contributor Author

zmike808 commented Nov 8, 2016

If you run "node ./server/workers/github.js" it will attempt to populate commits for all existing projects in the database. However, because the DB is not disconnecting, it will hang instead of closing after finishing. But you can browse the commits collection and view the data. Also, the commit api endpoints for users should be working. However, the project endpoint isn't working yet because the query is wrong.

@agundy
Copy link
Member

agundy commented Nov 15, 2016

@zmike808 have a chance to make any of the changes that Kiana has suggested?

@zmike808
Copy link
Contributor Author

Made a ton of changes. Much cleaner code & everything is currently working. Please check it out and let me know what you guys think so far, @kmcnellis @agundy. ALSO: Make sure to run npm install, since I switched to a different github API wrapper/library

@zmike808
Copy link
Contributor Author

zmike808 commented Dec 9, 2016

Status Update: almost done. Just need to integrate it with our endpoints. Know exactly what I have to do, just need to figure out how to do it in javascript & ExpressJS. Which sounds like it should be easy...but javascript.

Anyways, I'm planning on making a new branch and PR once I have everything done. Just to make things cleaner.

@agundy
Copy link
Member

agundy commented Dec 11, 2016

@zmike808 Sounds good! Let us know when we can look at it or if you need anything

@kmcnellis
Copy link
Member

I think its actually better to just leave it on this branch / pr, btw. It saves history for anyone looking back to see how it was done. It'll be squashed before merging anyways.

@zmike808
Copy link
Contributor Author

Hi, just wanted to drop a quick update. I know grades are due soon, and we were suppose to have everything in by today. I've been working on this last bit and it's been taking much longer than I thought. I am going to try to give it another hour or two, and if I can't get the api integration working, I'll just leave it as a function/on demand worker that can be run by nodejs cli.

@zmike808
Copy link
Contributor Author

I couldn't end up getting the endpoints to work. I ended up just adding a function into the worker which will grab commits for alll projects. I also added functions to the worker to get commits for a project with date filtering, i.e. before x, or after y.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants