Skip to content

Commit

Permalink
Merge pull request #221 from fga-eps-mds/revert-217-devel
Browse files Browse the repository at this point in the history
HOTFIX-RequestBugs
  • Loading branch information
BrunoOliveiraDantas authored May 24, 2019
2 parents dec3a4a + 8786272 commit d2b4f1e
Show file tree
Hide file tree
Showing 16 changed files with 379 additions and 780 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Code ###
.vscode/
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
Expand All @@ -25,4 +25,4 @@ export.sh

# Bot training
/ada/models/*
/ada/rasa_core.log
/ada/rasa_core.log
48 changes: 0 additions & 48 deletions ada/actions/create_issue.py

This file was deleted.

138 changes: 63 additions & 75 deletions ada/actions/get_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import os
from urllib3.exceptions import NewConnectionError
from requests.exceptions import HTTPError
import telegram
GITLAB_SERVICE_URL = os.getenv("GITLAB_SERVICE_URL", "")
ACCESS_TOKEN = os.environ.get("ACCESS_TOKEN", "")
SECS = 10.0


class Report(Action):
Expand All @@ -18,58 +15,51 @@ def run(self, dispatcher, tracker, domain):
headers = {'Content-Type': 'application/json'}
tracker_state = tracker.current_state()
chat_id = tracker_state["sender_id"]
try:
response = requests.get(GITLAB_SERVICE_URL +
"report/{chat_id}"
.format(chat_id=chat_id), timeout=SECS,
headers=headers)
except requests.exceptions.Timeout:
text = "Desculpa, não consegui fazer o que você me pediu! 😕"
bot = telegram.Bot(token=ACCESS_TOKEN)
bot = bot.send_message(chat_id=chat_id, text=text)
else:
report_project = response.json()
project = report_project[0]["project"]
dispatcher.utter_message("Primeiramente, o seu projeto "
"se chama {project_name}"
" e se encontra disponível "
"nesse site {web_url}"
.format(project_name=project["name"],
web_url=project["web_url"]))
text_message = "As branches do seu repositório "\
"são as seguintes:\n"
for item in report_project:
for value in item["branches"]["name"]:
text_message += "▪️ {names}\n".format(names=value)
dispatcher.utter_message(text_message)
commits = report_project[0]["commits"]["last_commit"]
dispatcher.utter_message("O último commit foi feito por"
"{author_name}"
"no dia {author_date} com o título"
"{title}.".format(
author_name=commits["author_name"],
author_date=commits["authored_date"],
title=commits["title"]))
response = requests.get(GITLAB_SERVICE_URL +
"report/{chat_id}"
.format(chat_id=chat_id), headers=headers)
report_project = response.json()
# print(report_project, file=sys.stderr)
project = report_project[0]["project"]
dispatcher.utter_message("Primeiramente, o seu projeto "
"se chama {project_name}"
" e se encontra disponível "
"nesse site {web_url}"
.format(project_name=project["name"],
web_url=project["web_url"]))

pipeline = report_project[0]["pipelines"]
dispatcher.utter_message("O atual pipeline possui id "
"{pipeline_id}"
"e nome {pipeline_name}"
.format(
pipeline_id=(
pipeline["current_pipeline_id"]),
pipeline_name=(
pipeline["current_pipeline_name"]
)))
text_message = "As branches do seu repositório são as seguintes:\n"
for item in report_project:
for value in item["branches"]["name"]:
text_message += "▪️ {names}\n".format(names=value)
dispatcher.utter_message(text_message)
commits = report_project[0]["commits"]["last_commit"]
dispatcher.utter_message("O último commit foi feito por"
"{author_name}"
"no dia {author_date} com o título"
"{title}.".format(
author_name=commits["author_name"],
author_date=commits["authored_date"],
title=commits["title"]))

dispatcher.utter_message("Sobre o projeto como um todo:\n📌 "
"Número total de pipelines: {total}\n"
"☑️ {success} obtiveram sucesso\n"
"❗️ {fail} falharam\n"
"☑️ A porcentagem de sucesso foi: "
"{perc_suc}%\n❗️ E a porcentagem "
"de falhas"
"foi: {perc_fail}%\n".format(
pipeline = report_project[0]["pipelines"]
dispatcher.utter_message("O atual pipeline possui id "
"{pipeline_id}"
"e nome {pipeline_name}"
.format(
pipeline_id=(
pipeline["current_pipeline_id"]),
pipeline_name=(
pipeline["current_pipeline_name"]
)))

dispatcher.utter_message("Sobre o projeto como um todo:\n📌 "
"Número total de pipelines: {total}\n"
"☑️ {success} obtiveram sucesso\n"
"❗️ {fail} falharam\n"
"☑️ A porcentagem de sucesso foi:"
"{perc_suc}\n❗️ E a porcentagem de falhas"
"foi: {perc_fail}\n".format(
total=(
pipeline["number_of_pipelines"]),
success=(
Expand All @@ -78,18 +68,17 @@ def run(self, dispatcher, tracker, domain):
perc_suc=(
pipeline["percent_succeded"]),
perc_fail=100-(
pipeline["percent_succeded"])))
pipeline["percent_succeded"])))

last_7 = pipeline["recents_pipelines"]["last_7_days"]
last_30 = pipeline["recents_pipelines"]["last_30_days"]
dispatcher.utter_message("Sobre os últimos 7 dias:\n⚒ "
"Número total de pipelines: {total}\n"
"☑️ {success} obtiveram sucesso\n"
"❗️ {fail} falharam\n"
"☑️ A porcentagem de sucesso foi: "
"{perc_suc}%\n❗️ E a porcentagem "
"de falhas"
"foi: {perc_fail}%\n".format(
last_7 = pipeline["recents_pipelines"]["last_7_days"]
last_30 = pipeline["recents_pipelines"]["last_30_days"]
dispatcher.utter_message("Sobre os últimos 7 dias:\n⚒ "
"Número total de pipelines: {total}\n"
"☑️ {success} obtiveram sucesso\n"
"❗️ {fail} falharam\n"
"☑️ A porcentagem de sucesso foi:"
"{perc_suc}\n❗️ E a porcentagem de falhas"
"foi: {perc_fail}\n".format(
total=(
last_7["number_of_pipelines"]),
success=(
Expand All @@ -98,16 +87,15 @@ def run(self, dispatcher, tracker, domain):
perc_suc=(
last_7["percent_succeded"]),
perc_fail=100-(
last_7["percent_succeded"])))
last_7["percent_succeded"])))

dispatcher.utter_message("Sobre os últimos 30 dias:\n⚒ "
"Número total de pipelines: {total}\n"
"☑️ {success} obtiveram sucesso\n"
"❗️ {fail} falharam\n"
"☑️ A porcentagem de sucesso foi:"
"{perc_suc}%\n❗️ E a porcentagem "
"de falhas"
"foi: {perc_fail}%\n".format(
dispatcher.utter_message("Sobre os últimos 30 dias:\n⚒ "
"Número total de pipelines: {total}\n"
"☑️ {success} obtiveram sucesso\n"
"❗️ {fail} falharam\n"
"☑️ A porcentagem de sucesso foi:"
"{perc_suc}\n❗️ E a porcentagem de falhas"
"foi: {perc_fail}\n".format(
total=(
last_30["number_of_pipelines"]),
success=(
Expand All @@ -116,8 +104,8 @@ def run(self, dispatcher, tracker, domain):
perc_suc=(
last_30["percent_succeded"]),
perc_fail=100-(
last_30["percent_succeded"])))
return []
last_30["percent_succeded"])))
return []
except HTTPError:
dispatcher.utter_message(
"Não estou conseguindo ter acesso a seus dados, tem certeza"
Expand Down
58 changes: 0 additions & 58 deletions ada/actions/rerun_pipeline.py

This file was deleted.

28 changes: 0 additions & 28 deletions ada/actions/set_issue_title.py

This file was deleted.

Loading

0 comments on commit d2b4f1e

Please sign in to comment.