Skip to content

Commit

Permalink
feat: modify cost_report_data and cost_report_config index
Browse files Browse the repository at this point in the history
Signed-off-by: ImMin5 <[email protected]>
  • Loading branch information
ImMin5 committed Jun 20, 2024
1 parent a5aa358 commit 64e0ff4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
9 changes: 2 additions & 7 deletions src/spaceone/cost_analysis/model/cost_report/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
class CostReport(MongoModel):
cost_report_id = StringField(max_length=40, generate_id="cost-report", unique=True)
cost = DictField(default={})
status = StringField(
max_length=20, choices=("IN_PROGRESS", "SUCCESS"), default="IN_PROGRESS"
)
status = StringField(max_length=20, choices=("IN_PROGRESS", "SUCCESS"))
report_number = StringField(max_length=255)
currency = StringField(choices=["KRW", "USD", "JPY"], default="KRW")
currency_date = StringField(max_length=20)
Expand Down Expand Up @@ -39,8 +37,5 @@ class CostReport(MongoModel):
"-created_at",
"-report_number",
],
"indexes": [
"cost_report_config_id",
"domain_id",
],
"indexes": ["cost_report_config_id", "status", "domain_id", "workspace_id"],
}
1 change: 1 addition & 0 deletions src/spaceone/cost_analysis/model/cost_report/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class CostReportGetRequest(BaseModel):
class CostReportSearchQueryRequest(BaseModel):
query: Union[dict, None] = None
cost_report_id: Union[str, None] = None
cost_report_config_id: Union[str, None] = None
status: Union[Status, None] = None
issue_date: Union[str, None] = None
workspace_name: Union[str, None] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ class CostReportConfig(MongoModel):
"created_at",
],
"ordering": ["-created_at"],
"indexes": [
"state",
"domain_id",
"cost_report_config_id",
],
"indexes": ["state", "domain_id"],
}

@queryset_manager
Expand Down
3 changes: 0 additions & 3 deletions src/spaceone/cost_analysis/model/cost_report_data/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"CostReportDataStatQueryRequest",
]

State = Literal["ENABLED", "DISABLED", "PENDING"]
AuthType = Literal["LOCAL", "EXTERNAL"]


class CostReportDataSearchQueryRequest(BaseModel):
query: Union[dict, None] = None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime
from typing import Union, List
from pydantic import BaseModel

from spaceone.core import utils

__all__ = ["CostReportDataResponse", "CostReportsDataResponse"]
Expand Down
14 changes: 12 additions & 2 deletions src/spaceone/cost_analysis/service/cost_report_serivce.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ def get(self, params: CostReportGetRequest) -> Union[CostReportResponse, dict]:
)
@append_query_filter(
[
"cost_report_id",
"cost_report_config_id",
"status",
"workspace_id",
"domain_id",
"workspace_id",
"cost_report_id",
]
)
@append_keyword_filter(
Expand Down Expand Up @@ -174,6 +175,15 @@ def list(
]
return CostReportsResponse(results=cost_reports_info, total_count=total_count)

@transaction(
permission="cost-analysis:CostReport.read",
role_types=["DOMAIN_ADMIN", "WORKSPACE_OWNER"],
)
@append_query_filter(["cost_config_report_id", "domain_id"])
@convert_model
def analyze(self):
pass

@transaction(
permission="cost-analysis:CostReport.read",
role_types=["DOMAIN_ADMIN", "WORKSPACE_OWNER"],
Expand Down

0 comments on commit 64e0ff4

Please sign in to comment.