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
Merge requests
!36
Master
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Master
master
into
production
Overview
0
Commits
2
Pipelines
1
Changes
1
Merged
Tim Repke
requested to merge
master
into
production
1 year ago
Overview
0
Commits
2
Pipelines
1
Changes
1
Expand
0
0
Merge request reports
Compare
production
production (base)
and
latest version
latest version
f6a52edb
2 commits,
1 year ago
1 file
+
12
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
server/api/routes/project/items.py
+
12
−
1
Options
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.twitter
import
TwitterItemModel
@@ -13,6 +13,7 @@ from nacsos_data.db.crud.items.twitter import \
read_all_twitter_items_for_project_paged
,
\
read_twitter_item_by_item_id
,
\
import_tweet
from
sqlalchemy
import
select
from
server.api.errors
import
ItemNotFoundError
from
server.data
import
db_engine
@@ -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
}
'
)
@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
)
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
)
Loading