Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
meanspec-hwinfo-daemon
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
MeanSpec (SCE338 2024-2 Group 1)
meanspec-hwinfo-daemon
Compare revisions
c06193e613c3ed66dc52d82440d6fac9f54de5d4 to e29240f274a3c41828e24c611ec6602daaa2a06f
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
meanspec/meanspec-hwinfo-daemon
Select target project
No results found
e29240f274a3c41828e24c611ec6602daaa2a06f
Select Git revision
Branches
master
1 result
Swap
Target
meanspec/meanspec-hwinfo-daemon
Select target project
meanspec/meanspec-hwinfo-daemon
1 result
c06193e613c3ed66dc52d82440d6fac9f54de5d4
Select Git revision
Branches
master
1 result
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
chore: ci/cd 완료 시 인프라에 자동 반영되도록 업데이트 지원
· 77b51371
Eunhak Lee
authored
5 months ago
Verified
77b51371
feat: 이미 parts 들이 등록돼있는 경우 조합을 재활용 함
· e29240f2
Eunhak Lee
authored
5 months ago
Verified
e29240f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+2
-0
2 additions, 0 deletions
.gitlab-ci.yml
push_to_db.py
+41
-12
41 additions, 12 deletions
push_to_db.py
with
43 additions
and
12 deletions
.gitlab-ci.yml
View file @
e29240f2
...
...
@@ -19,6 +19,8 @@ deploy:
-
docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
-
docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
-
docker push $CI_REGISTRY_IMAGE:latest
-
>
apk add curl && curl -H "Host: signal-server" http://hub.enak.kr/hwinfo || true
after_script
:
-
docker logout $CI_REGISTRY
This diff is collapsed.
Click to expand it.
push_to_db.py
View file @
e29240f2
...
...
@@ -73,6 +73,20 @@ RETURNING part_id;""".format(type=_part_type_enum, columns=columns, value_entrie
return
None
def
check_if_parts_exist
(
_cursor
,
_user_id
,
_part_ids
):
sql
=
"""
WITH result AS (SELECT combinations.id AS combination_id,
ARRAY(SELECT part_id FROM relations WHERE relations.combination_id = combinations.id ORDER BY relations.part_id) AS parts
FROM combinations WHERE combinations.owner_id = %s) SELECT combination_id FROM result WHERE parts = %s;
"""
_cursor
.
execute
(
sql
,
(
_user_id
,
_part_ids
))
data
=
_cursor
.
fetchall
()
if
not
data
:
return
None
_existing_combination_id
=
data
[
-
1
][
-
1
]
return
_existing_combination_id
def
create_combination
(
_cursor
,
nickname
,
_user_id
):
_pc_name
=
"
새 PC
"
if
nickname
:
...
...
@@ -140,6 +154,7 @@ def func():
_parts
=
parse
.
handle_xml_body
(
_xml_document
)
_part_ids
=
[]
_created_parts
=
False
print
(
"
Matching parts
"
)
...
...
@@ -157,6 +172,7 @@ def func():
_matched_id
=
match_part_obj_into_db
(
part
,
part_type
)
if
not
_matched_id
:
# DB에 없는 부품이라면
_created_parts
=
True
print
(
"
.. creating new part with
"
,
part
[
"
name
"
])
with
db_conn
.
cursor
()
as
cursor
:
_matched_id
=
create_new_one
(
part
,
part_type
,
cursor
)
...
...
@@ -167,21 +183,34 @@ def func():
continue
print
(
f
"
[WARNING] failed to match part type=
{
part_type
}
, part:
"
,
part
,
file
=
sys
.
stderr
)
print
(
"
Creating combination
"
)
with
db_conn
.
cursor
()
as
cursor
:
_combination_id
=
create_combination
(
cursor
,
None
,
_user_id
)
if
not
_combination_id
:
print
(
"
Failed to create combination
"
,
file
=
sys
.
stderr
)
exit
(
1
)
print
(
"
Wiring parts
"
,
_part_ids
,
"
to combination id
"
,
_combination_id
)
with
db_conn
.
cursor
()
as
cursor
:
wire_part_to_combination
(
cursor
,
_combination_id
,
*
_part_ids
)
_combination_id
=
None
# 이미 존재하는 경우
if
not
_created_parts
:
print
(
"
Checking combination existance
"
)
with
db_conn
.
cursor
()
as
cursor
:
_combination_id
=
check_if_parts_exist
(
cursor
,
_user_id
,
_part_ids
)
print
(
"
Committing to DB
"
)
db_conn
.
commit
()
if
_combination_id
is
not
None
:
print
(
"
Combination exist. Using combination id
"
,
_combination_id
)
# 새로 추가하는 경우
if
_combination_id
is
not
None
:
print
(
"
Creating combination
"
)
with
db_conn
.
cursor
()
as
cursor
:
_combination_id
=
create_combination
(
cursor
,
None
,
_user_id
)
if
not
_combination_id
:
print
(
"
Failed to create combination
"
,
file
=
sys
.
stderr
)
exit
(
1
)
print
(
"
Wiring parts
"
,
_part_ids
,
"
to combination id
"
,
_combination_id
)
with
db_conn
.
cursor
()
as
cursor
:
wire_part_to_combination
(
cursor
,
_combination_id
,
*
_part_ids
)
print
(
"
Committing to DB
"
)
db_conn
.
commit
()
print
(
"
Finalizing transaction
"
)
with
db_conn
.
cursor
()
as
cursor
:
...
...
This diff is collapsed.
Click to expand it.