Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
NACSOS Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MCC APSIS
NACSOS
NACSOS Core
Commits
d5f8a698
Commit
d5f8a698
authored
1 year ago
by
Tim Repke
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into 'production'
Master See merge request
!36
parents
6fc4ec5a
f6a52edb
No related branches found
Branches containing commit
No related tags found
1 merge request
!36
Master
Pipeline
#1256
passed
1 year ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/api/routes/project/items.py
+12
-1
12 additions, 1 deletion
server/api/routes/project/items.py
with
12 additions
and
1 deletion
server/api/routes/project/items.py
+
12
−
1
View file @
d5f8a698
from
fastapi
import
APIRouter
,
Depends
,
HTTPException
,
status
,
Query
from
fastapi
import
APIRouter
,
Depends
,
HTTPException
,
status
,
Query
from
nacsos_data.db.schemas
import
Project
,
ItemTypeLiteral
,
GenericItem
,
AcademicItem
,
ItemType
from
nacsos_data.db.schemas
import
Project
,
ItemTypeLiteral
,
GenericItem
,
AcademicItem
,
ItemType
,
Item
from
nacsos_data.models.items
import
AnyItemModel
,
GenericItemModel
,
AcademicItemModel
,
AnyItemModelList
from
nacsos_data.models.items
import
AnyItemModel
,
GenericItemModel
,
AcademicItemModel
,
AnyItemModelList
from
nacsos_data.models.items.twitter
import
TwitterItemModel
from
nacsos_data.models.items.twitter
import
TwitterItemModel
...
@@ -13,6 +13,7 @@ from nacsos_data.db.crud.items.twitter import \
...
@@ -13,6 +13,7 @@ from nacsos_data.db.crud.items.twitter import \
read_all_twitter_items_for_project_paged
,
\
read_all_twitter_items_for_project_paged
,
\
read_twitter_item_by_item_id
,
\
read_twitter_item_by_item_id
,
\
import_tweet
import_tweet
from
sqlalchemy
import
select
from
server.api.errors
import
ItemNotFoundError
from
server.api.errors
import
ItemNotFoundError
from
server.data
import
db_engine
from
server.data
import
db_engine
...
@@ -86,6 +87,16 @@ async def get_detail_for_item(item_id: str,
...
@@ -86,6 +87,16 @@ async def get_detail_for_item(item_id: str,
raise
ItemNotFoundError
(
f
'
No item found with type
{
item_type
}
with the id
{
item_id
}
'
)
raise
ItemNotFoundError
(
f
'
No item found with type
{
item_type
}
with the id
{
item_id
}
'
)
@router.get
(
'
/text/{item_id}
'
,
response_model
=
str
)
async
def
get_text_for_item
(
item_id
:
str
,
permission
=
Depends
(
UserPermissionChecker
(
'
dataset_read
'
)))
->
str
:
async
with
db_engine
.
session
()
as
session
:
stmt
=
select
(
Item
.
text
).
where
(
Item
.
item_id
==
item_id
)
text
:
str
|
None
=
await
session
.
scalar
(
stmt
)
if
text
is
None
:
raise
ItemNotFoundError
(
f
'
No text available for item with ID:
{
item_id
}
'
)
return
text
@router.get
(
'
/count
'
,
response_model
=
int
)
@router.get
(
'
/count
'
,
response_model
=
int
)
async
def
count_project_items
(
permission
=
Depends
(
UserPermissionChecker
(
'
dataset_read
'
)))
->
int
:
async
def
count_project_items
(
permission
=
Depends
(
UserPermissionChecker
(
'
dataset_read
'
)))
->
int
:
tweets
=
await
read_item_count_for_project
(
project_id
=
permission
.
permissions
.
project_id
,
engine
=
db_engine
)
tweets
=
await
read_item_count_for_project
(
project_id
=
permission
.
permissions
.
project_id
,
engine
=
db_engine
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment