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

Automatické postovanie do fóra. #7

Merged
merged 14 commits into from
Feb 4, 2016

Conversation

martinsabo
Copy link
Contributor

V code review už môžeme pokračovať priamo v PR. Momentálne je to urobené tak, aby boli notifiery plne kompatibilné reps. zameniteľné. Teda implementujú ten istý interface, ktorý je podchytený v base triede.

@@ -0,0 +1,18 @@
require 'discourse_api'

class DiscourseClient < DiscourseApi::Client
Copy link
Member

Choose a reason for hiding this comment

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

Toto nerozumiem co riesi.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chcel som aby bol Discourse notifier zavisly iba na interface injektnuteho klienta. A tento koncept narusal fakt, ze musim chytat custom exception class z discourse gemu. Tak som urobil nas discource klient, ktory momentalne len wrapne ten z gemu a takisto prelozi ich exception na exception nasho klienta.

A tu exception potrebujem na to, aby som vedel odfiltrovat discourse api errory od ostatnych.


module Uvobot
module Notifications
class Base
Copy link
Member

Choose a reason for hiding this comment

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

AbstractNotifier alebo rovno Notifier

@notifier.no_announcements_found
end
end
require_relative './uvobot/worker'
Copy link
Member

Choose a reason for hiding this comment

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

Toto ./uvobot/worker nepoznam, ja pouzivam require_relative 'uvobot/worker'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nechapem. Nepaci sa ti ze tam volam cely namespace naraz, alebo ze tam je bodka v ceste?

Copy link
Member

Choose a reason for hiding this comment

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

Ta bodka, podla mna to je zbytocne.

@jsuchal
Copy link
Member

jsuchal commented Feb 3, 2016

Ak ta to prestane bavit tak povedz. Nech nemame z toho blby pocit obaja.

@@ -0,0 +1,8 @@
require_relative 'notifications/notifier'
Copy link
Member

Choose a reason for hiding this comment

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

Cely tento subor notifiactions.rb podla mna moze ist prec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moze. Pouzivam to na skupinovy require, ked rozpisem jednotlive notifiers nebude ho treba.

def announcement_to_topic(announcement)
detail = @scraper.get_announcement_detail(announcement[:link][:href])

{
Copy link
Member

Choose a reason for hiding this comment

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

Tu mi chyba to osetrenie, ze ked je detail nil = nepodarilo sa ho extrahovat tak to vytvori topic s linkom ale default spravou, ze k tomu obstarku sa nepodarilo nic viac vytiahnut.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Je to tam ponate tak, ze metoda detail_message da namiesto ceny spravu o nepodarenej extrakcii. A link na detail/zdroj obstaravania, maju hned pod tym.

To fakt chces tvorit zvlast topic s oznamom ze sa nepodarilo vytiahnut cenu pre kazde obstaravanie co ma iny format?

Copy link
Member

Choose a reason for hiding this comment

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

Inak, ak sa nepodari vytiahnut ziadne data tak by to malo vytvorit stale topic. Ak sa nepodari len cenu tak je to v pohode tak ako to je teraz.

EDIT: Ah! uz to vidim. Dobre. Nic.

@martinsabo
Copy link
Contributor Author

Z coho presne mas blby pocit? Nebavi ta nekonecny code review? :)

detail = {}
h_doc = doc(html)
amount_node = h_doc.xpath('//div[text()="Hodnota "]').css('span').first
fail Uvobot::ParsingError, 'Amount node not found.' if amount_node.nil?
Copy link
Member

Choose a reason for hiding this comment

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

Toto si stale myslim, ze je v kontexte parsovania uplne bezna situacia, cize by sa normalny control flow nemal robit cez Exception. nech to vrati nil. Aj tak sa to odchytava hned vyssie. Neni to exception co chytas cez "4 poschodia".

@jsuchal
Copy link
Member

jsuchal commented Feb 4, 2016

Mna hej, len ci nemas pocit, ze uz moc rypem.

@martinsabo
Copy link
Contributor Author

Beriem to ako mentoring. Plus to má zjavne pozitívny dopad na kód :).

@@ -0,0 +1,55 @@
require_relative 'notifier'
require_relative '../uvo_scraper'
Copy link
Member

Choose a reason for hiding this comment

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

Toto tu uz byt nemusi.

@martinsabo
Copy link
Contributor Author

Ked toto dobojujeme, mozem sa pozriet aj na to "nenotifikovanie" cez vikend.

UvoScraper.new(UvoParser)
notifiers = [
Uvobot::Notifications::SlackNotifier.new(ENV.fetch('UVOBOT_SLACK_WEBHOOK')),
Uvobot::Notifications::DiscourseNotifier.new(discourse_client, 'Štátne projekty', Uvobot::UvoScraper.new)
Copy link
Member

Choose a reason for hiding this comment

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

Este mi toto vytiahni do env DISCOURSE_TARGET_CATEGORY a moze byt.

jsuchal added a commit that referenced this pull request Feb 4, 2016
Automatické postovanie do fóra, closes #2
@jsuchal jsuchal merged commit ee9cf7c into slovensko-digital:master Feb 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants