2 Commits

Author SHA1 Message Date
Sense T
e02bca8ad2 fix bug 2024-01-13 13:26:53 +08:00
Sense T
fe13b65016 k8s deploy method 2024-01-13 12:59:31 +08:00
4 changed files with 47 additions and 3 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
target
.direnv
*.db
deploy/**/config

View File

@@ -0,0 +1,27 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hangitbot
spec:
selector:
matchLabels:
app: hangitbot
template:
metadata:
labels:
app: hangitbot
spec:
containers:
- name: hangitbot
image: <Image>
resources:
limits:
memory: "64Mi"
cpu: "100m"
envFrom:
- secretRef:
name: hangitbot
env:
- name: API_URL
value: https://tgapi.sense-t.eu.org/

View File

@@ -0,0 +1,13 @@
# yaml-language-server: $schema=https://json.schemastore.org/kustomization.json
resources:
- deployment.yaml
secretGenerator:
- name: hangitbot
files:
- config/DATABASE_URI
- config/TGBOT_TOKEN
images:
- name: <Image>
newName: ghcr.io/senseab/hangitbot
newTag: v0.0.1

View File

@@ -83,9 +83,12 @@ impl Controller {
let query = match chat.is_group() || chat.is_supergroup() {
true => {
Stats::find()
Stats::find().select_only()
.column(StatsColumn::Name)
.column_as(StatsColumn::Counts.sum(), "counts")
.filter(StatsColumn::GroupId.eq(chat.id.0))
.order_by_desc(StatsColumn::Counts)
.group_by(StatsColumn::Name)
.order_by_desc(StatsColumn::Counts.sum())
.limit(LIMIT).into_model()
.all(&transcation)
.await