Skip to content

Commit 6d9f0b2

Browse files
authored
Merge pull request #40 from /issues/39
Members' local times
2 parents 33cdcbc + 733b3ae commit 6d9f0b2

File tree

35 files changed

+1243
-9
lines changed

35 files changed

+1243
-9
lines changed

.deploy/lambda/lib/JProfByBotStack.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ export class JProfByBotStack extends cdk.Stack {
5555
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
5656
removalPolicy: cdk.RemovalPolicy.DESTROY,
5757
});
58+
const timezonesTable = new dynamodb.Table(this, 'jprof-by-bot-table-timezones', {
59+
tableName: 'jprof-by-bot-table-timezones',
60+
partitionKey: {name: 'user', type: dynamodb.AttributeType.NUMBER},
61+
sortKey: {name: 'chat', type: dynamodb.AttributeType.NUMBER},
62+
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
63+
removalPolicy: cdk.RemovalPolicy.DESTROY,
64+
});
5865

5966
pinsTable.addGlobalSecondaryIndex({
6067
indexName: 'chatId',
@@ -66,6 +73,12 @@ export class JProfByBotStack extends cdk.Stack {
6673
partitionKey: {name: 'userId', type: dynamodb.AttributeType.NUMBER},
6774
projectionType: dynamodb.ProjectionType.ALL,
6875
});
76+
timezonesTable.addGlobalSecondaryIndex({
77+
indexName: 'username',
78+
partitionKey: {name: 'username', type: dynamodb.AttributeType.STRING},
79+
sortKey: {name: 'chat', type: dynamodb.AttributeType.NUMBER},
80+
projectionType: dynamodb.ProjectionType.ALL,
81+
});
6982

7083
const lambdaUnpin = new lambda.Function(this, 'jprof-by-bot-lambda-unpin', {
7184
functionName: 'jprof-by-bot-lambda-unpin',
@@ -123,6 +136,7 @@ export class JProfByBotStack extends cdk.Stack {
123136
'TABLE_QUIZOJIS': quizojisTable.tableName,
124137
'TABLE_MONIES': moniesTable.tableName,
125138
'TABLE_PINS': pinsTable.tableName,
139+
'TABLE_TIMEZONES': timezonesTable.tableName,
126140
'STATE_MACHINE_UNPINS': stateMachineUnpin.stateMachineArn,
127141
'TOKEN_TELEGRAM_BOT': props.telegramToken,
128142
'TOKEN_YOUTUBE_API': props.youtubeToken,
@@ -144,6 +158,8 @@ export class JProfByBotStack extends cdk.Stack {
144158
pinsTable.grantReadWriteData(lambdaWebhook);
145159
pinsTable.grantReadWriteData(lambdaUnpin);
146160

161+
timezonesTable.grantReadWriteData(lambdaWebhook);
162+
147163
stateMachineUnpin.grantStartExecution(lambdaWebhook)
148164

149165
const api = new apigateway.RestApi(this, 'jprof-by-bot-api', {

.github/workflows/default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
- run: quizoji/dynamodb/src/test/resources/seed.sh
6262
- run: monies/dynamodb/src/test/resources/seed.sh
6363
- run: pins/dynamodb/src/test/resources/seed.sh
64+
- run: times/timezones/dynamodb/src/test/resources/seed.sh
6465
- run: ./gradlew clean dbTest
6566
- uses: actions/upload-artifact@v2
6667
if: always()

gradle/wrapper/gradle-wrapper.jar

1.19 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ set -- \
205205
org.gradle.wrapper.GradleWrapperMain \
206206
"$@"
207207

208+
# Stop when "xargs" is not available.
209+
if ! command -v xargs >/dev/null 2>&1
210+
then
211+
die "xargs is not available"
212+
fi
213+
208214
# Use "xargs" to parse quoted args.
209215
#
210216
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

gradlew.bat

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@rem limitations under the License.
1515
@rem
1616

17-
@if "%DEBUG%" == "" @echo off
17+
@if "%DEBUG%"=="" @echo off
1818
@rem ##########################################################################
1919
@rem
2020
@rem Gradle startup script for Windows
@@ -25,7 +25,7 @@
2525
if "%OS%"=="Windows_NT" setlocal
2626

2727
set DIRNAME=%~dp0
28-
if "%DIRNAME%" == "" set DIRNAME=.
28+
if "%DIRNAME%"=="" set DIRNAME=.
2929
set APP_BASE_NAME=%~n0
3030
set APP_HOME=%DIRNAME%
3131

@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4040

4141
set JAVA_EXE=java.exe
4242
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto execute
43+
if %ERRORLEVEL% equ 0 goto execute
4444

4545
echo.
4646
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7575

7676
:end
7777
@rem End local scope for the variables with windows NT shell
78-
if "%ERRORLEVEL%"=="0" goto mainEnd
78+
if %ERRORLEVEL% equ 0 goto mainEnd
7979

8080
:fail
8181
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8282
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84-
exit /b 1
83+
set EXIT_CODE=%ERRORLEVEL%
84+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
85+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86+
exit /b %EXIT_CODE%
8587

8688
:mainEnd
8789
if "%OS%"=="Windows_NT" endlocal

monies/dynamodb/src/test/kotlin/by/jprof/telegram/bot/monies/dynamodb/dao/MoniesDAOTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient
1818
@Tag("db")
1919
@ExtendWith(DynamoDB::class)
2020
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
21-
internal class VotesDAOTest {
21+
internal class MoniesDAOTest {
2222
@AWSClient(endpoint = Endpoint::class)
2323
private lateinit var dynamoDB: DynamoDbAsyncClient
2424
private lateinit var sut: MoniesDAO

runners/lambda/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ dependencies {
2222
implementation(project.projects.currencies)
2323
implementation(project.projects.herald.processor)
2424
implementation(project.projects.leetcode)
25+
implementation(project.projects.times.timezones.dynamodb)
26+
implementation(project.projects.times)
2527
}

runners/lambda/src/main/kotlin/by/jprof/telegram/bot/runners/lambda/config/database.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import by.jprof.telegram.bot.kotlin.dao.KotlinMentionsDAO
55
import by.jprof.telegram.bot.monies.dao.MoniesDAO
66
import by.jprof.telegram.bot.pins.dao.PinDAO
77
import by.jprof.telegram.bot.quizoji.dao.QuizojiDAO
8+
import by.jprof.telegram.bot.times.timezones.dao.TimeZoneDAO
89
import by.jprof.telegram.bot.votes.dao.VotesDAO
910
import by.jprof.telegram.bot.youtube.dao.YouTubeChannelsWhitelistDAO
1011
import kotlinx.serialization.ExperimentalSerializationApi
@@ -14,10 +15,11 @@ import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient
1415
import by.jprof.telegram.bot.dialogs.dynamodb.dao.DialogStateDAO as DynamoDBDialogStateDAO
1516
import by.jprof.telegram.bot.kotlin.dynamodb.dao.KotlinMentionsDAO as DynamoDBKotlinMentionsDAO
1617
import by.jprof.telegram.bot.monies.dynamodb.dao.MoniesDAO as DynamoDBMoniesDAO
18+
import by.jprof.telegram.bot.pins.dynamodb.dao.PinDAO as DynamoDBPinDAO
1719
import by.jprof.telegram.bot.quizoji.dynamodb.dao.QuizojiDAO as DynamoDBQuizojiDAO
20+
import by.jprof.telegram.bot.times.timezones.dynamodb.dao.TimeZoneDAO as DynamoDBTimeZoneDAO
1821
import by.jprof.telegram.bot.votes.dynamodb.dao.VotesDAO as DynamoDBVotesDAO
1922
import by.jprof.telegram.bot.youtube.dynamodb.dao.YouTubeChannelsWhitelistDAO as DynamoDBYouTubeChannelsWhitelistDAO
20-
import by.jprof.telegram.bot.pins.dynamodb.dao.PinDAO as DynamoDBPinDAO
2123

2224
@ExperimentalSerializationApi
2325
val databaseModule = module {
@@ -73,4 +75,11 @@ val databaseModule = module {
7375
get(named(TABLE_PINS))
7476
)
7577
}
78+
79+
single<TimeZoneDAO> {
80+
DynamoDBTimeZoneDAO(
81+
get(),
82+
get(named(TABLE_TIMEZONES))
83+
)
84+
}
7685
}

runners/lambda/src/main/kotlin/by/jprof/telegram/bot/runners/lambda/config/env.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const val TABLE_DIALOG_STATES = "TABLE_DIALOG_STATES"
1212
const val TABLE_QUIZOJIS = "TABLE_QUIZOJIS"
1313
const val TABLE_MONIES = "TABLE_MONIES"
1414
const val TABLE_PINS = "TABLE_PINS"
15+
const val TABLE_TIMEZONES = "TABLE_TIMEZONES"
1516
const val STATE_MACHINE_UNPINS = "STATE_MACHINE_UNPINS"
1617

1718
val envModule = module {
@@ -25,6 +26,7 @@ val envModule = module {
2526
TABLE_QUIZOJIS,
2627
TABLE_MONIES,
2728
TABLE_PINS,
29+
TABLE_TIMEZONES,
2830
STATE_MACHINE_UNPINS,
2931
).forEach { variable ->
3032
single(named(variable)) {

0 commit comments

Comments
 (0)