Skip to content

Commit 15f9b77

Browse files
authored
chore: some updates (#165)
1 parent 8e70670 commit 15f9b77

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

apps/web-app/server/tasks/ai/daily-report.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { repository } from '@roll-stack/database'
33
import { format } from 'date-fns'
44
import { ru } from 'date-fns/locale/ru'
55
import OpenAI from 'openai'
6-
import { useAtriumBot } from '~~/server/services/telegram/atrium-bot'
76

87
const logger = useLogger('task:ai:daily-report')
98

@@ -19,7 +18,7 @@ export default defineTask({
1918
}
2019

2120
try {
22-
const { ai, telegram } = useRuntimeConfig()
21+
const { ai } = useRuntimeConfig()
2322

2423
const tasks = await repository.task.listCompletedToday()
2524
const preparedTasks = tasks.map((task) => ({
@@ -55,30 +54,30 @@ export default defineTask({
5554

5655
// Flow item
5756
const date = format(new Date(), 'd MMMM', { locale: ru })
58-
const flowItem = await repository.flow.createItem({
57+
await repository.flow.createItem({
5958
type: 'daily_task_report',
6059
title: `Задачи ${date}`,
6160
description: finalMessage,
6261
})
6362

64-
const separator = 'zzzzz'
65-
const startAppData = `flow${separator}${flowItem?.id}`
63+
// const separator = 'zzzzz'
64+
// const startAppData = `flow${separator}${flowItem?.id}`
6665

67-
// Get first words
68-
const messageIntro = finalMessage.split(' ').slice(0, 40).join(' ')
69-
const preparedMessage = `${messageIntro}...\n\nПродолжение внутри Атриума? 🙃`
66+
// // Get first words
67+
// const messageIntro = finalMessage.split(' ').slice(0, 40).join(' ')
68+
// const preparedMessage = `${messageIntro}...\n\nПродолжение внутри Атриума? 🙃`
7069

71-
await useAtriumBot().api.sendMessage(telegram.teamGroupId, preparedMessage, {
72-
link_preview_options: {
73-
is_disabled: true,
74-
},
75-
reply_markup: {
76-
inline_keyboard: [[{
77-
text: '👉 Открыть Атриум',
78-
url: `https://t.me/sushi_atrium_bot/app?startapp=${startAppData}`,
79-
}]],
80-
},
81-
})
70+
// await useAtriumBot().api.sendMessage(telegram.teamGroupId, preparedMessage, {
71+
// link_preview_options: {
72+
// is_disabled: true,
73+
// },
74+
// reply_markup: {
75+
// inline_keyboard: [[{
76+
// text: '👉 Открыть Атриум',
77+
// url: `https://t.me/sushi_atrium_bot/app?startapp=${startAppData}`,
78+
// }]],
79+
// },
80+
// })
8281
} catch (error) {
8382
errorResolver(error)
8483
}

packages/database/src/repository/partner.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class Partner {
3232
}
3333

3434
static async listWithData() {
35-
return useDatabase().query.partners.findMany({
35+
const partners = await useDatabase().query.partners.findMany({
3636
where: (partners, { eq }) => eq(partners.isActive, true),
3737
with: {
3838
kitchens: true,
@@ -48,6 +48,13 @@ export class Partner {
4848
users: true,
4949
},
5050
})
51+
52+
// Order by name of legal entity
53+
return partners.sort((a, b) => {
54+
const aName = a.legalEntity?.name || ''
55+
const bName = b.legalEntity?.name || ''
56+
return aName.localeCompare(bName)
57+
})
5158
}
5259

5360
static async listAgreements() {

packages/database/src/repository/user.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class User {
7070
static async list() {
7171
return useDatabase().query.users.findMany({
7272
where: (users, { eq }) => eq(users.isActive, true),
73+
orderBy: (users, { asc }) => asc(users.surname),
7374
with: {
7475
focusedTask: true,
7576
telegramUsers: true,

0 commit comments

Comments
 (0)