Skip to content

Commit

Permalink
Merge pull request #49 from daithihearn/alexa-bug
Browse files Browse the repository at this point in the history
fix: alexa skill failed when there was no expensive period
  • Loading branch information
daithihearn authored Oct 28, 2023
2 parents 78cb427 + 9e6d2d5 commit 8c5df93
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.16.3
1.16.4
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.springframework.boot.runApplication
info = Info(
title =
"Electricity Prices API",
version = "1.16.3",
version = "1.16.4",
description = "Returns PVPC electricity prices for a given range"
),
servers = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,14 @@ class AlexSkillService(private val priceService: PriceService, private val messa
val expensivePeriods =
getExpensivePeriods(pricesToday, thirtyDayAverage)

if (expensivePeriods.isEmpty()) throw Exception("No expensive periods found")
if (expensivePeriods.isEmpty()) return messageSource.getMessage(
"alexa.next.expensive.period.no_data",
emptyArray(),
locale
)

val nextPeriod = getNextPeriod(expensivePeriods, dateTime) ?: return messageSource.getMessage(
"alexa.next.expensive.period.no_data",
"alexa.next.expensive.period.none_left",
emptyArray(),
locale
)
Expand Down
21 changes: 11 additions & 10 deletions src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ alexa.today.rating.normal=Today is a normal day with an average price of {0} cen
alexa.tomorrow.rating.good=Tomorrow is a good day with an average price of {0} cents per kilowatt-hour.
alexa.tomorrow.rating.bad=Tomorrow is a bad day with an average price of {0} cents per kilowatt-hour.
alexa.tomorrow.rating.normal=Tomorrow is a normal day with an average price of {0} cents per kilowatt-hour.
alexa.tomorrow.periods.cheap.single.start=There is only 1 good period.
alexa.tomorrow.periods.cheap.multiple.start=There are {0} good periods.
alexa.tomorrow.periods.expensive.single.start=There is only one bad period.
alexa.tomorrow.periods.expensive.multiple.start=There are {0} bad periods.
alexa.tomorrow.periods.cheap.single.start=There is only 1 cheap period.
alexa.tomorrow.periods.cheap.multiple.start=There are {0} cheap periods.
alexa.tomorrow.periods.expensive.single.start=There is only one expensive period.
alexa.tomorrow.periods.expensive.multiple.start=There are {0} expensive periods.
alexa.tomorrow.periods.item=From {0} to {1} with an average price of {2} cents.
alexa.tomorrow.no_data=There is no data available yet for tomorrow. Please check back later. Prices are generally available by 8:30 PM.
alexa.next.cheap.period=The next low period starts at {0} with an average price of {2} cents per kilowatt-hour and will end at {1}.
alexa.next.cheap.period.no_data=The low periods for today have already passed.
alexa.current.cheap.period=You are currently in a low period that started at {0} with an average price of {2} cents per kilowatt-hour and will end at {1}.
alexa.next.expensive.period=The next high period starts at {0} with an average price of {2} cents per kilowatt-hour and will end at {1}.
alexa.next.expensive.period.no_data=The high period for today has already passed.
alexa.current.expensive.period=You are currently in a high period that started at {0} with an average price of {2} cents per kilowatt-hour and will end at {1}.
alexa.next.cheap.period=The next cheap period starts at {0} with an average price of {2} cents per kilowatt-hour and will end at {1}.
alexa.next.cheap.period.no_data=The cheap periods for today have already passed.
alexa.current.cheap.period=You are currently in a cheap period that started at {0} with an average price of {2} cents per kilowatt-hour and will end at {1}.
alexa.next.expensive.period=The next expensive period starts at {0} with an average price of {2} cents per kilowatt-hour and will end at {1}.
alexa.next.expensive.period.no_data=There are no expensive periods today.
alexa.next.expensive.period.none_left=The expensive periods for today have already passed.
alexa.current.expensive.period=You are currently in a expensive period that started at {0} with an average price of {2} cents per kilowatt-hour and will end at {1}.
alexa.thirty.day.average=The average price for the last 30 days is {0} cents per kilowatt-hour.
alexa.daily.average=The average price today is {0} cents per kilowatt-hour.
alexa.today.no_data=There is no data available yet for today. Please check back later.
Expand Down
19 changes: 10 additions & 9 deletions src/main/resources/i18n/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ alexa.today.rating.normal=Hoy es un día normal, con un precio medio de {0} cén
alexa.tomorrow.rating.good=Mañana es un día bueno, con un precio promedio de {0} céntimos por kilovatio-hora.
alexa.tomorrow.rating.bad=Mañana es un día malo, con un precio promedio de {0} céntimos por kilovatio-hora.
alexa.tomorrow.rating.normal=Mañana es un día normal, con un precio promedio de {0} céntimos por kilovatio-hora.
alexa.tomorrow.periods.cheap.single.start=Solo hay un período bajo.
alexa.tomorrow.periods.cheap.multiple.start=Hay {0} períodos bajos.
alexa.tomorrow.periods.cheap.single.start=Solo hay un período barato.
alexa.tomorrow.periods.cheap.multiple.start=Hay {0} períodos baratos.
alexa.tomorrow.periods.expensive.single.start=Solo hay un período alto.
alexa.tomorrow.periods.expensive.multiple.start=Hay {0} períodos altos.
alexa.tomorrow.periods.item=Desde las {0} hasta las {1} con un precio promedio de {2} céntimos.
alexa.tomorrow.no_data=Aún no hay datos disponibles para mañana. Por favor, vuelva más tarde. Los precios están generalmente disponibles a las 8:30 PM.
alexa.next.cheap.period=El próximo período bajo comienza a las {0} con un precio medio de {2} céntimos por kilovatio-hora y terminara a las {1}.
alexa.next.cheap.period.no_data=Los periodos bajos de hoy ya han pasado.
alexa.current.cheap.period=Actualmente se encuentra en un período bajo que comenzó a las {0} con un precio promedio de {2} céntimos por kilovatio-hora y terminara a las {1}.
alexa.next.expensive.period=El próximo período alto comienza a las {0} con un precio promedio de {2} céntimos por kilovatio-hora y terminara a las {1}.
alexa.next.expensive.period.no_data=El período alto de hoy ya ha pasado.
alexa.current.expensive.period=Actualmente se encuentra en un período alto que comenzó a las {0} con un precio promedio de {2} céntimos por kilovatio-hora y terminara a las {1}.
alexa.next.cheap.period=El próximo período barato comienza a las {0} con un precio medio de {2} céntimos por kilovatio-hora y terminara a las {1}.
alexa.next.cheap.period.no_data=Los periodos baratos de hoy ya han pasado.
alexa.current.cheap.period=Actualmente se encuentra en un período barato que comenzó a las {0} con un precio promedio de {2} céntimos por kilovatio-hora y terminara a las {1}.
alexa.next.expensive.period=El próximo período caro comienza a las {0} con un precio promedio de {2} céntimos por kilovatio-hora y terminara a las {1}.
alexa.next.expensive.period.no_data=Hoy no hay ningun período caro.
alexa.next.expensive.period.none_left=Los períodos caros de hoy ya ha pasado.
alexa.current.expensive.period=Actualmente se encuentra en un período caro que comenzó a las {0} con un precio promedio de {2} céntimos por kilovatio-hora y terminara a las {1}.
alexa.thirty.day.average=El precio promedio de los últimos 30 días es {0} céntimos por kilovatio-hora.
alexa.daily.average=El precio promedio de hoy es {0} céntimos por kilovatio-hora.
alexa.today.no_data=No hay datos disponibles para hoy. Por favor, vuelva más tarde.
alexa.current.price=El precio actual es {0} céntimos por kilovatio-hora.
alexa.welcome=Bienvenido a la habilidad de los precios de la electricidad. Dime, dame una actualización completa.
alexa.cancel=Hasta luego!
alexa.help=Esta skill le permite obtener información sobre el precio de la electricidad en España. Puede preguntar por el precio actual, el precio promedio de hoy, el precio promedio de los últimos 30 días, el próximo período bajo, el próximo período alto, el período bajo actual y el período alto actual. También puede preguntar por el precio de mañana. Que le gustaría saber?
alexa.help=Esta skill le permite obtener información sobre el precio de la electricidad en España. Puede preguntar por el precio actual, el precio promedio de hoy, el precio promedio de los últimos 30 días, el próximo período barato, el próximo período alto, el período barato actual y el período alto actual. También puede preguntar por el precio de mañana. Que le gustaría saber?
alexa.stop=Hasta luego!

0 comments on commit 8c5df93

Please sign in to comment.