Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mi): add owner_id to applets response (M2-6948) #1402

Merged
merged 4 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/apps/applets/api/applets.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ async def applet_retrieve(
applet_future = service.get_single_language_by_id(applet_id, language)
subject_future = SubjectsService(session, user.id).get_by_user_and_applet(user.id, applet_id)
applet, subject = await asyncio.gather(applet_future, subject_future)
applet_owner = await UserAppletAccessCRUD(session).get_applet_owner(applet_id)
applet.owner_id = applet_owner.owner_id
return AppletRetrieveResponse(
result=AppletSingleLanguageDetailPublic.from_orm(applet),
respondent_meta={"nickname": subject.nickname if subject else None, "tag": subject.tag if subject else None},
Expand Down
1 change: 1 addition & 0 deletions src/apps/applets/domain/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ class AppletFetchBase(AppletReportConfigurationBase, AppletBaseInfo):
created_at: datetime.datetime | None
updated_at: datetime.datetime | None
is_published: bool = False
owner_id: uuid.UUID | None
5 changes: 5 additions & 0 deletions src/apps/applets/service/applet.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ async def get_list_by_single_language(

for schema in schemas:
theme = theme_map.get(schema.theme_id)
applet_owner = await UserAppletAccessCRUD(self.session).get_applet_owner(schema.id)
applets.append(
AppletSingleLanguageInfo(
id=schema.id,
Expand All @@ -429,6 +430,7 @@ async def get_list_by_single_language(
stream_enabled=schema.stream_enabled,
stream_ip_address=schema.stream_ip_address,
stream_port=schema.stream_port,
owner_id=applet_owner.owner_id,
)
)
return applets
Expand Down Expand Up @@ -677,6 +679,9 @@ async def get_full_applet(self, applet_id: uuid.UUID) -> AppletFull:
applet = AppletFull.from_orm(schema)
applet.activities = await ActivityService(self.session, self.user_id).get_full_activities(applet_id)
applet.activity_flows = await FlowService(self.session).get_full_flows(applet_id)
applet_owner = await UserAppletAccessCRUD(self.session).get_applet_owner(applet_id)
applet.owner_id = applet_owner.owner_id

return applet

async def publish(self, applet_id: uuid.UUID):
Expand Down
Loading