mirror of
https://github.com/MichaByte/OnBoard-Live.git
synced 2025-12-06 15:03:40 -05:00
slack modal work
This commit is contained in:
parent
b062611fec
commit
492a644f56
6 changed files with 94 additions and 4 deletions
|
|
@ -264,6 +264,7 @@ async def github_callback(request: Request):
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"block_id": "session-checks",
|
||||||
"type": "section",
|
"type": "section",
|
||||||
"text": {
|
"text": {
|
||||||
"type": "mrkdwn",
|
"type": "mrkdwn",
|
||||||
|
|
@ -376,8 +377,35 @@ async def handle_app_home_opened_events(body, logger, event, client):
|
||||||
|
|
||||||
|
|
||||||
@bolt.action("submit_sessions")
|
@bolt.action("submit_sessions")
|
||||||
async def submit_sessions(ack, body):
|
async def submit_sessions(ack: AsyncAck, body):
|
||||||
await ack()
|
await ack()
|
||||||
|
selected_sessions_ts: List[str] = [
|
||||||
|
i["text"]["text"].split("session on ")[1]
|
||||||
|
for i in body["state"]["values"]["session-checks"]["checkboxes"][
|
||||||
|
"selected_options"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
pr_id = int(
|
||||||
|
body["message"]["blocks"][1]["text"]["text"].split("#")[1].split(":")[0]
|
||||||
|
) # don't tell my mom she raised a monster
|
||||||
|
db_pr = await db.pullrequest.find_first_or_raise(where={"github_id": pr_id})
|
||||||
|
if db_pr.user_id:
|
||||||
|
stream_key = (
|
||||||
|
await db.stream.find_first_or_raise(where={"user_id": db_pr.user_id})
|
||||||
|
).key
|
||||||
|
for session in selected_sessions_ts:
|
||||||
|
await db.session.create(
|
||||||
|
{
|
||||||
|
"pull": {"connect": {"id": db_pr.id}},
|
||||||
|
"timestamp": session,
|
||||||
|
"filename": f"/home/onboard/recordings/{stream_key}/{datetime.strptime(session, '%Y-%m-%dT%H:%M:%S.%fZ').strftime('%Y-%m-%d_%H-%M-%S-%f')}.mp4",
|
||||||
|
"duration": get_recording_duration(session, stream_key),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
await bolt.client.chat_delete(
|
||||||
|
channel=body["container"]["channel_id"], ts=body["message"]["ts"]
|
||||||
|
)
|
||||||
|
print(pr_id, selected_sessions_ts)
|
||||||
|
|
||||||
|
|
||||||
@bolt.action("deny")
|
@bolt.action("deny")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Session" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"user_id" TEXT NOT NULL,
|
||||||
|
"timestamp" TEXT NOT NULL,
|
||||||
|
"filename" TEXT NOT NULL,
|
||||||
|
"duration" INTEGER NOT NULL,
|
||||||
|
"reviewed" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"approved" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
CONSTRAINT "Session_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Session_user_id_key" ON "Session"("user_id");
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the column `user_id` on the `Session` table. All the data in the column will be lost.
|
||||||
|
- Added the required column `pr_id` to the `Session` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- RedefineTables
|
||||||
|
PRAGMA defer_foreign_keys=ON;
|
||||||
|
PRAGMA foreign_keys=OFF;
|
||||||
|
CREATE TABLE "new_Session" (
|
||||||
|
"id" TEXT NOT NULL PRIMARY KEY,
|
||||||
|
"pr_id" INTEGER NOT NULL,
|
||||||
|
"timestamp" TEXT NOT NULL,
|
||||||
|
"filename" TEXT NOT NULL,
|
||||||
|
"duration" INTEGER NOT NULL,
|
||||||
|
"reviewed" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
"approved" BOOLEAN NOT NULL DEFAULT false,
|
||||||
|
CONSTRAINT "Session_pr_id_fkey" FOREIGN KEY ("pr_id") REFERENCES "PullRequest" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
INSERT INTO "new_Session" ("approved", "duration", "filename", "id", "reviewed", "timestamp") SELECT "approved", "duration", "filename", "id", "reviewed", "timestamp" FROM "Session";
|
||||||
|
DROP TABLE "Session";
|
||||||
|
ALTER TABLE "new_Session" RENAME TO "Session";
|
||||||
|
CREATE UNIQUE INDEX "Session_pr_id_key" ON "Session"("pr_id");
|
||||||
|
PRAGMA foreign_keys=ON;
|
||||||
|
PRAGMA defer_foreign_keys=OFF;
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- DropIndex
|
||||||
|
DROP INDEX "Session_pr_id_key";
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- A unique constraint covering the columns `[filename]` on the table `Session` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Session_filename_key" ON "Session"("filename");
|
||||||
|
|
@ -34,4 +34,16 @@ model PullRequest {
|
||||||
user_id String?
|
user_id String?
|
||||||
gh_user_id Int
|
gh_user_id Int
|
||||||
user User? @relation("PullRequestToUser", fields: [user_id], references: [id])
|
user User? @relation("PullRequestToUser", fields: [user_id], references: [id])
|
||||||
|
sessions Session[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Session {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
pr_id Int
|
||||||
|
pull PullRequest @relation(fields: [pr_id], references: [id])
|
||||||
|
timestamp String
|
||||||
|
filename String @unique
|
||||||
|
duration Int // in minutes
|
||||||
|
reviewed Boolean @default(false)
|
||||||
|
approved Boolean @default(false)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue