Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Initial work for integration with YouTube API #94

Merged
merged 7 commits into from
May 18, 2019

Conversation

thornycrackers
Copy link
Member

This is not ready to be merged in yet, but I think we can start the review process now that there's enough work. I'm not sure where some of the logic is supposed to sit so I figured it would just be easier to get another set of eyes on it so as I finish this up I can move logic to the appropriate places

@alysivji
Copy link
Member

Apologies for not really having a clear definition of done for this feature. Need to start getting better at writing stories.

Is this going to be like the Twitter feature where we post new videos in a Slack channel?

@thornycrackers
Copy link
Member Author

thornycrackers commented Mar 17, 2019 via email

Copy link
Member

@alysivji alysivji left a comment

Choose a reason for hiding this comment

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

Looks good so far.

Tests would really help make code review a bit easier. We can go over testing in BB/Flask if you have questions.

db.session.add(youtube_video)
db.session.commit()
return 'post to slack'
return make_response(200, json={"run": "complete"})
Copy link
Member

Choose a reason for hiding this comment

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

Would this only post the latest video?

Our video person posts in batches so we could have up to 10 videos at once.

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently yes, only the latest would be shared. I will update this so that it posts all new videos. If busy-beaver has an empty YoutubeVideo table do you think a good default would be just post the latest video?

Copy link
Member

Choose a reason for hiding this comment

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

Yah. That definitely makes sense to me.

I don't like the idea of checking for an empty table every time but cannot offer any meaningful alternatives. Let's proceed this way for now, but start thinking about a better of dealing with this edge case.

We had the same issue for the Twitter key-value store. I manually did the work, which I didn't like, but it was a one-time thing. Now that we are thinking about installing this app in other workspaces, we should think about a better way forward.

Maybe we can populate the database once on application start? But that would require all contributors to have all keys to guarantee things work.

A separate script?

@thornycrackers
Copy link
Member Author

thornycrackers commented Mar 18, 2019 via email

@thornycrackers
Copy link
Member Author

@alysivji I've update this pull request. I broke the logic up a little bit, added the posting of multiple videos as well as posting to slack. I was using httpie for testing and tested with the following command.

http POST "http://localhost:32770/poll-youtube" 'Authorization:token <value>' channel=codytest

I tested both with no videos in the database as well as with multiple new videos and they posted correctly to slack so I think that this is working as intended. I will look at adding some tests if you think the code looks aight.

@alysivji
Copy link
Member

This is looking good! Thanks for getting it updated.

Taking a look at the cody-test channel, could we space out videos by a configurable timedelta? Looks like if we post them all at once, Slack doesn't unfurl the URL to show the meta HTML information.

I'm currently adding a task queue to the project; right now I'm testing it in an example project. Should be completed in the next couple of days; might have you refactor to kick off a background job when making a request to the poller. Shouldn't be too large of a change on your end.

@alysivji
Copy link
Member

Also, loving the video selection! I totally forgot about Big Wreck. I have their first 2 CDs from back in the day.

@codecov-io
Copy link

codecov-io commented May 14, 2019

Codecov Report

Merging #94 into master will decrease coverage by 2.79%.
The diff coverage is 49.36%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #94     +/-   ##
=========================================
- Coverage   93.36%   90.57%   -2.8%     
=========================================
  Files          41       43      +2     
  Lines         919      997     +78     
=========================================
+ Hits          858      903     +45     
- Misses         61       94     +33
Impacted Files Coverage Δ
busy_beaver/models/__init__.py 100% <100%> (ø) ⬆️
busy_beaver/blueprints/tasks/__init__.py 100% <100%> (ø) ⬆️
busy_beaver/adapters/__init__.py 100% <100%> (ø) ⬆️
busy_beaver/config.py 100% <100%> (ø) ⬆️
busy_beaver/blueprints/tasks/youtube_post.py 31.91% <31.91%> (ø)
busy_beaver/adapters/youtube.py 45.45% <44.44%> (+45.45%) ⬆️
busy_beaver/models/youtube_video.py 80% <80%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7b8a91c...a8de01d. Read the comment docs.

@thornycrackers
Copy link
Member Author

@alysivji I added an environment variable to sleep in between posts!

Copy link
Member

@alysivji alysivji left a comment

Choose a reason for hiding this comment

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

lgtm! Just one change to get tests to pass

Thanks for getting this done!

busy_beaver/__init__.py Outdated Show resolved Hide resolved
@alysivji alysivji self-requested a review May 17, 2019 18:30
Copy link
Member

@alysivji alysivji left a comment

Choose a reason for hiding this comment

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

LGTM!

@alysivji
Copy link
Member

alysivji commented May 17, 2019

This is awesome! Thanks so much @thornycrackers!

I'm gonna merge this in the next couple of days and work with our YouTube person to ensure we have proper video names so I can enable this feature for the ChiPy workspace.

To enable, we'll need a shell script that hits the polling endpoint and then we'll have to set up a CRON job in Ansible. Created a new task, #146.

@alysivji alysivji changed the title [Work in Progress] Initial work for integrate with youtube api Initial work for integration with YouTube API May 17, 2019
This was referenced May 17, 2019
@alysivji alysivji merged commit 8f8727e into busy-beaver-dev:master May 18, 2019
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.

3 participants