Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
altlinux-packages-bot
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Unitsaev
altlinux-packages-bot
Commits
e0b551e3
Verified
Commit
e0b551e3
authored
Jul 12, 2025
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add statistics
parent
18281836
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
3 deletions
+89
-3
methods.py
src/api/methods.py
+13
-0
models.py
src/api/models.py
+20
-0
menu.py
src/data/keyboards/menu.py
+3
-0
help.py
src/handlers/help.py
+1
-1
profile.py
src/handlers/profile.py
+3
-1
start.py
src/handlers/start.py
+5
-1
statistics.py
src/handlers/statistics.py
+44
-0
No files found.
src/api/methods.py
View file @
e0b551e3
...
@@ -37,6 +37,18 @@ class APIInfo:
...
@@ -37,6 +37,18 @@ class APIInfo:
return
models
.
APIVersion
(
**
data
)
return
models
.
APIVersion
(
**
data
)
class
PackagesetInfo
:
def
__init__
(
self
,
client
:
BaseAPI
):
self
.
client
=
client
async
def
repository_statistics
(
self
,
branch
:
str
|
None
=
None
)
->
models
.
RepositoryStatisticsModel
:
if
branch
:
data
=
await
self
.
client
.
get
(
"/packageset/repository_statistics"
,
{
"branch"
:
branch
})
else
:
data
=
await
self
.
client
.
get
(
"/packageset"
)
return
models
.
RepositoryStatisticsModel
(
**
data
)
class
BugInfo
:
class
BugInfo
:
def
__init__
(
self
,
client
:
BaseAPI
):
def
__init__
(
self
,
client
:
BaseAPI
):
self
.
client
=
client
self
.
client
=
client
...
@@ -76,6 +88,7 @@ class PackagesAPI:
...
@@ -76,6 +88,7 @@ class PackagesAPI:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
_client
=
BaseAPI
()
self
.
_client
=
BaseAPI
()
self
.
api
=
APIInfo
(
self
.
_client
)
self
.
api
=
APIInfo
(
self
.
_client
)
self
.
packageset
=
PackagesetInfo
(
self
.
_client
)
self
.
bug
=
BugInfo
(
self
.
_client
)
self
.
bug
=
BugInfo
(
self
.
_client
)
self
.
site
=
SiteInfo
(
self
.
_client
)
self
.
site
=
SiteInfo
(
self
.
_client
)
...
...
src/api/models.py
View file @
e0b551e3
...
@@ -8,6 +8,26 @@ class APIVersion(BaseModel):
...
@@ -8,6 +8,26 @@ class APIVersion(BaseModel):
description
:
str
description
:
str
class
RepositoryStatisticsPackageCountsModel
(
BaseModel
):
arch
:
str
component
:
str
count
:
int
size
:
int
size_hr
:
str
uuid
:
str
class
RepositoryStatisticsBranchesModel
(
BaseModel
):
branch
:
str
date_update
:
str
packages_count
:
List
[
RepositoryStatisticsPackageCountsModel
]
class
RepositoryStatisticsModel
(
BaseModel
):
length
:
int
branches
:
List
[
RepositoryStatisticsBranchesModel
]
class
AllMaintainersElementModel
(
BaseModel
):
class
AllMaintainersElementModel
(
BaseModel
):
packager_name
:
str
packager_name
:
str
packager_nickname
:
str
packager_nickname
:
str
...
...
src/data/keyboards/menu.py
View file @
e0b551e3
...
@@ -3,4 +3,6 @@ from telegrinder import Button, Keyboard
...
@@ -3,4 +3,6 @@ from telegrinder import Button, Keyboard
menu_kb
=
(
menu_kb
=
(
Keyboard
()
Keyboard
()
.
add
(
Button
(
"Профиль"
))
.
add
(
Button
(
"Профиль"
))
.
row
()
.
add
(
Button
(
"Статистика"
))
)
.
get_markup
()
)
.
get_markup
()
\ No newline at end of file
src/handlers/help.py
View file @
e0b551e3
...
@@ -5,7 +5,7 @@ from api import api
...
@@ -5,7 +5,7 @@ from api import api
dp
=
Dispatch
()
dp
=
Dispatch
()
@dp.message
(
Command
(
"info"
))
@dp.message
(
Command
(
"
altrepo_
info"
))
async
def
info_handler
(
m
:
Message
)
->
None
:
async
def
info_handler
(
m
:
Message
)
->
None
:
api_data
=
await
api
.
api
.
version
()
api_data
=
await
api
.
api
.
version
()
await
m
.
answer
(
await
m
.
answer
(
...
...
src/handlers/profile.py
View file @
e0b551e3
from
telegrinder
import
Dispatch
,
Message
,
CallbackQuery
from
telegrinder
import
Dispatch
,
Message
,
CallbackQuery
from
telegrinder.rules
import
Command
,
PayloadEqRule
,
Text
from
telegrinder.rules
import
Command
,
PayloadEqRule
,
Text
,
IsUser
from
api
import
api
from
api
import
api
from
api.models
import
BugzillaInfoModel
from
api.models
import
BugzillaInfoModel
...
@@ -7,8 +7,10 @@ from api.models import BugzillaInfoModel
...
@@ -7,8 +7,10 @@ from api.models import BugzillaInfoModel
from
services.menu
import
send_menu
from
services.menu
import
send_menu
from
database.models
import
User
from
database.models
import
User
dp
=
Dispatch
()
dp
=
Dispatch
()
dp
.
message
.
auto_rules
=
IsUser
()
@dp.message
(
Command
(
"profile"
)
|
Text
([
"profile"
,
"профиль"
],
ignore_case
=
True
))
@dp.message
(
Command
(
"profile"
)
|
Text
([
"profile"
,
"профиль"
],
ignore_case
=
True
))
async
def
profile_handler
(
m
:
Message
,
user
:
User
|
None
)
->
None
:
async
def
profile_handler
(
m
:
Message
,
user
:
User
|
None
)
->
None
:
...
...
src/handlers/start.py
View file @
e0b551e3
from
telegrinder
import
MESSAGE_FROM_USER
,
Dispatch
,
Message
,
WaiterMachine
from
telegrinder
import
MESSAGE_FROM_USER
,
Dispatch
,
Message
,
WaiterMachine
from
telegrinder.rules
import
StartCommand
,
HasText
from
telegrinder.rules
import
StartCommand
,
HasText
,
IsUser
from
database.func
import
DB
from
database.func
import
DB
from
database.models
import
User
from
database.models
import
User
...
@@ -7,11 +7,14 @@ from database.models import User
...
@@ -7,11 +7,14 @@ from database.models import User
from
data.keyboards
import
start_keyboards
from
data.keyboards
import
start_keyboards
from
api
import
api
from
api
import
api
from
services.menu
import
send_menu
from
config
import
DEFAUIL_BRANCHES
from
config
import
DEFAUIL_BRANCHES
dp
=
Dispatch
()
dp
=
Dispatch
()
wm
=
WaiterMachine
(
dp
)
wm
=
WaiterMachine
(
dp
)
dp
.
message
.
auto_rules
=
IsUser
()
@dp.message
(
StartCommand
())
@dp.message
(
StartCommand
())
async
def
start_handler
(
m
:
Message
,
user
:
User
|
None
)
->
None
:
async
def
start_handler
(
m
:
Message
,
user
:
User
|
None
)
->
None
:
...
@@ -63,3 +66,4 @@ async def start_handler(m: Message, user: User | None) -> None:
...
@@ -63,3 +66,4 @@ async def start_handler(m: Message, user: User | None) -> None:
maintainer
,
maintainer
,
branch
branch
)
)
await
send_menu
(
m
,
user
)
src/handlers/statistics.py
0 → 100644
View file @
e0b551e3
from
telegrinder
import
MESSAGE_FROM_USER
,
Dispatch
,
Message
,
WaiterMachine
,
CallbackQuery
from
telegrinder.rules
import
Command
,
PayloadEqRule
,
Text
,
IsUser
from
datetime
import
datetime
import
locale
from
api
import
api
from
services.menu
import
send_menu
from
database.models
import
User
dp
=
Dispatch
()
wm
=
WaiterMachine
(
dp
)
@dp.message
(
Command
(
"statistics"
))
@dp.message
(
Text
([
"statistics"
,
"статистика"
],
ignore_case
=
True
),
IsUser
())
async
def
profile_handler
(
m
:
Message
,
user
:
User
|
None
)
->
None
:
statistics_data
=
(
await
api
.
packageset
.
repository_statistics
(
user
.
default_branch
))
.
branches
[
0
]
locale
.
setlocale
(
locale
.
LC_TIME
,
'ru_RU.UTF-8'
)
statistics_date
=
(
datetime
.
fromisoformat
(
statistics_data
.
date_update
))
.
strftime
(
"
%-
d
%
B
%
Y г."
)
statistics_message
=
f
"{statistics_data.branch.capitalize()} ({statistics_date})
\n\n
"
for
packages
in
statistics_data
.
packages_count
:
statistics_message
+=
f
"Архитектура: {packages.arch} ({packages.component})
\n
"
statistics_message
+=
f
"Пакеты: {packages.count} - {packages.size_hr}
\n\n
"
await
m
.
answer
(
statistics_message
)
@dp.callback_query
(
PayloadEqRule
(
"command/menu"
),
IsUser
())
async
def
menu_handler
(
cb
:
CallbackQuery
,
user
:
User
|
None
):
send_menu
(
cb
,
user
)
@dp.message
(
Command
([
"menu"
,
"меню"
])
|
Text
([
"меню"
,
"menu"
]),
IsUser
())
async
def
menu_handler
(
m
:
Message
,
user
:
User
|
None
):
await
send_menu
(
m
,
user
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment