-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from WoongyuChoi/dev
Dev
- Loading branch information
Showing
9 changed files
with
118 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ class Config: | |
CACHE_TYPE = "FileSystemCache" | ||
CACHE_DIR = "/tmp" | ||
CACHE_DEFAULT_TIMEOUT = 60 | ||
JSON_AS_ASCII = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
from .param_defaults import default_params | ||
from .json_response import json_utf8_response | ||
|
||
__all__ = ["default_params"] | ||
__all__ = [ | ||
"default_params", | ||
"json_utf8_response", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from functools import wraps | ||
from flask import Response | ||
import json | ||
|
||
|
||
def json_utf8_response(func): | ||
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
result, status_code = func(*args, **kwargs) | ||
return Response( | ||
json.dumps(result, ensure_ascii=False), | ||
mimetype="application/json", | ||
status=status_code, | ||
) | ||
|
||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,35 @@ | ||
import inspect | ||
from functools import wraps | ||
from utils import get_first_day_of_last_month, get_last_day_of_last_month | ||
|
||
from utils import ( | ||
get_first_day_of_last_month, | ||
get_first_month_of_last_year, | ||
get_last_day_of_last_month, | ||
get_last_month_of_last_year, | ||
) | ||
|
||
|
||
def default_params(func): | ||
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
kwargs["start_date"] = kwargs.get("start_date") or get_first_day_of_last_month() | ||
kwargs["end_date"] = kwargs.get("end_date") or get_last_day_of_last_month() | ||
func_signature = inspect.signature(func) | ||
func_params = func_signature.parameters | ||
|
||
if "start_date" in func_params: | ||
kwargs["start_date"] = ( | ||
kwargs.get("start_date") or get_first_day_of_last_month() | ||
) | ||
if "end_date" in func_params: | ||
kwargs["end_date"] = kwargs.get("end_date") or get_last_day_of_last_month() | ||
if "start_month" in func_params: | ||
kwargs["start_month"] = ( | ||
kwargs.get("start_month") or get_first_month_of_last_year() | ||
) | ||
if "end_month" in func_params: | ||
kwargs["end_month"] = ( | ||
kwargs.get("end_month") or get_last_month_of_last_year() | ||
) | ||
|
||
return func(*args, **kwargs) | ||
|
||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters