-
Notifications
You must be signed in to change notification settings - Fork 0
Merge to main #16
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
Merge to main #16
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # Glances μ¬μ© κ°μ΄λ | ||
|
|
||
| ## μ€μΉ μλ£ | ||
| glances 3.4.0.3 λ²μ μ΄ μ€μΉλμμ΅λλ€. | ||
|
|
||
| ## κΈ°λ³Έ μ¬μ©λ² | ||
|
|
||
| ### ν°λ―Έλμμ μ€μκ° λͺ¨λν°λ§ | ||
| ```bash | ||
| glances | ||
| ``` | ||
|
|
||
| ### μΉ μλ² λͺ¨λλ‘ μ€ν (μ격 μ μ κ°λ₯) | ||
| ```bash | ||
| # κΈ°λ³Έ ν¬νΈ(61208)λ‘ μ€ν | ||
| glances -w | ||
|
|
||
| # νΉμ ν¬νΈ μ§μ | ||
| glances -w -p 61208 | ||
|
|
||
| # νΉμ IPμμλ§ μ μ νμ© (보μ κ°ν) | ||
| glances -w -B 0.0.0.0 -p 61208 | ||
| ``` | ||
|
|
||
| μΉ λΈλΌμ°μ μμ μ μ: `http://μλ²IP:61208` | ||
|
|
||
| ### RESTful API λͺ¨λ | ||
| ```bash | ||
| glances -s | ||
| ``` | ||
|
|
||
| ### CPU, λ©λͺ¨λ¦¬, λμ€ν¬, λ€νΈμν¬λ§ κ°λ¨ν 보기 | ||
| ```bash | ||
| glances --percpu | ||
| ``` | ||
|
|
||
| ## μ£Όμ λ¨μΆν€ | ||
|
|
||
| - `q` λλ `ESC`: μ’ λ£ | ||
| - `h`: λμλ§ | ||
| - `c`: CPU μ 보 νμ/μ¨κΉ | ||
| - `m`: λ©λͺ¨λ¦¬ μ 보 νμ/μ¨κΉ | ||
| - `d`: λμ€ν¬ μ 보 νμ/μ¨κΉ | ||
| - `n`: λ€νΈμν¬ μ 보 νμ/μ¨κΉ | ||
| - `p`: νλ‘μΈμ€ μ λ ¬ λ³κ²½ | ||
| - `w`: κ²½κ³ μμ | ||
| - `x`: κ²½κ³ /μ€μ μκ³κ° μμ | ||
|
|
||
| ## μλΉμ€λ‘ μ€ν | ||
|
|
||
| glancesκ° systemd μλΉμ€λ‘ μλ λ±λ‘λμ΄ μμ΅λλ€. | ||
|
|
||
| ```bash | ||
| # μλΉμ€ μμ | ||
| sudo systemctl start glances | ||
|
|
||
| # μλΉμ€ μ€μ§ | ||
| sudo systemctl stop glances | ||
|
|
||
| # μλΉμ€ μν νμΈ | ||
| sudo systemctl status glances | ||
|
|
||
| # λΆν μ μλ μμ νμ±ν | ||
| sudo systemctl enable glances | ||
| ``` | ||
|
|
||
| ## λ°±κ·ΈλΌμ΄λ μ€ν | ||
|
|
||
| ```bash | ||
| # nohupμΌλ‘ λ°±κ·ΈλΌμ΄λ μ€ν | ||
| nohup glances -w > /dev/null 2>&1 & | ||
|
|
||
| # tmux/screen μ¬μ© | ||
| tmux new-session -d -s monitoring 'glances' | ||
| ``` | ||
|
|
||
| ## μ μ©ν μ΅μ | ||
|
|
||
| - `--refresh 2`: 2μ΄λ§λ€ κ°±μ (κΈ°λ³Έκ°: 3μ΄) | ||
| - `--disable-plugin docker`: Docker νλ¬κ·ΈμΈ λΉνμ±ν | ||
| - `--enable-plugin docker`: Docker νλ¬κ·ΈμΈ νμ±ν | ||
| - `--percpu`: CPU μ½μ΄λ³ μ¬μ©λ νμ | ||
| - `--process-short-name`: μ§§μ νλ‘μΈμ€ μ΄λ¦ νμ | ||
| - `--time`: μκ° νμ | ||
|
|
||
| ## μμ: μΉ λͺ¨λλ‘ λ°±κ·ΈλΌμ΄λ μ€ν | ||
|
|
||
| ```bash | ||
| # μΉ μλ² λͺ¨λλ‘ λ°±κ·ΈλΌμ΄λ μ€ν | ||
| glances -w -B 0.0.0.0 -p 61208 & | ||
| ``` | ||
|
|
||
| λΈλΌμ°μ μμ `http://μλ²IP:61208` μ μνμ¬ λͺ¨λν°λ§ κ°λ₯ν©λλ€. | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,8 @@ | |
| UserInfoResponse, CareInfoResponse, | ||
| FcmTokenRegisterRequest, FcmTokenRegisterResponse, FcmTokenDeactivateResponse, | ||
| NotificationListResponse, | ||
| TopEmotionResponse, CareTopEmotionResponse | ||
| TopEmotionResponse, CareTopEmotionResponse, | ||
| AnalysisResultResponse, WeeklyAnalysisCombinedResponse, FrequencyAnalysisCombinedResponse | ||
| ) | ||
| from .care_service import CareService | ||
| import random | ||
|
|
@@ -361,24 +362,35 @@ async def upload_voice_with_question( | |
| else: | ||
| raise HTTPException(status_code=400, detail=result["message"]) | ||
|
|
||
| @users_router.get("/voices/analyzing/frequency") | ||
| @users_router.get("/voices/analyzing/frequency", response_model=FrequencyAnalysisCombinedResponse) | ||
| async def get_user_emotion_frequency(username: str, month: str, db: Session = Depends(get_db)): | ||
| """μ¬μ©μ λ³ΈμΈμ νλ¬κ° κ°μ λΉλμ μ§κ³""" | ||
| voice_service = get_voice_service(db) | ||
| result = voice_service.get_user_emotion_monthly_frequency(username, month) | ||
| if not result.get("success"): | ||
| raise HTTPException(status_code=400, detail=result.get("message", "μ‘°ν μ€ν¨")) | ||
| return result | ||
| """μ¬μ©μ λ³ΈμΈμ μκ° λΉλ μ’ ν©λΆμ(OpenAI μΊμ + κΈ°μ‘΄ λΉλ κ²°κ³Ό)""" | ||
| from .services.analysis_service import get_frequency_result | ||
| try: | ||
| message = get_frequency_result(db, username=username, is_care=False) | ||
| voice_service = get_voice_service(db) | ||
| base = voice_service.get_user_emotion_monthly_frequency(username, month) | ||
| frequency = base.get("frequency", {}) if base.get("success") else {} | ||
| return FrequencyAnalysisCombinedResponse(message=message, frequency=frequency) | ||
| except Exception as e: | ||
| raise HTTPException(status_code=400, detail=f"λΆμ μ€ν¨: {str(e)}") | ||
|
|
||
| @users_router.get("/voices/analyzing/weekly") | ||
| @users_router.get("/voices/analyzing/weekly", response_model=WeeklyAnalysisCombinedResponse) | ||
| async def get_user_emotion_weekly(username: str, month: str, week: int, db: Session = Depends(get_db)): | ||
| """μ¬μ©μ λ³ΈμΈμ μ/μ£Όμ°¨λ³ μμΌλ³ top κ°μ μμ½""" | ||
| voice_service = get_voice_service(db) | ||
| result = voice_service.get_user_emotion_weekly_summary(username, month, week) | ||
| """μ¬μ©μ λ³ΈμΈμ μ£Όκ° μ’ ν©λΆμ(OpenAI μΊμ μ¬μ©)""" | ||
| from .services.analysis_service import get_weekly_result | ||
| try: | ||
| message = get_weekly_result(db, username=username, is_care=False) | ||
| # κΈ°μ‘΄ μ£Όκ° μμ½λ ν¨κ» μ 곡 | ||
| voice_service = get_voice_service(db) | ||
| weekly_result = voice_service.get_user_emotion_weekly_summary(username, month, week) | ||
| weekly = weekly_result.get("weekly", []) if weekly_result.get("success") else [] | ||
| return WeeklyAnalysisCombinedResponse(message=message, weekly=weekly) | ||
| except Exception as e: | ||
| raise HTTPException(status_code=400, detail=f"λΆμ μ€ν¨: {str(e)}") | ||
|
Comment on lines
+378
to
+390
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. get_user_emotion_weekly μλν¬μΈνΈμ λμΌν μμΈ μ²λ¦¬ μ΄μ Line 365-376μμ μ§μ ν μμΈ μ²λ¦¬ λ¬Έμ κ° μ΄ μλν¬μΈνΈμλ λμΌνκ² μ‘΄μ¬ν©λλ€. λμΌν μμ μ¬νμ μ μ©νμΈμ. π§° Toolsπͺ Ruff (0.14.3)379-379: Do not perform function call (B008) 389-389: Do not catch blind exception: (BLE001) 390-390: Within an (B904) 390-390: Use explicit conversion flag Replace with conversion flag (RUF010) π€ Prompt for AI Agents |
||
|
|
||
| if not result.get("success"): | ||
| raise HTTPException(status_code=400, detail=result.get("message", "μ‘°ν μ€ν¨")) | ||
| return result | ||
|
|
||
|
|
||
|
|
||
|
|
||
| @users_router.get("/top_emotion", response_model=TopEmotionResponse) | ||
|
|
@@ -529,26 +541,49 @@ async def get_care_user_voice_list( | |
| result = voice_service.get_care_voice_list(care_username, date=date) | ||
| return CareUserVoiceListResponse(success=result["success"], voices=result.get("voices", [])) | ||
|
|
||
| @care_router.get("/users/voices/analyzing/frequency") | ||
| @care_router.get("/users/voices/analyzing/frequency", response_model=FrequencyAnalysisCombinedResponse) | ||
| async def get_emotion_monthly_frequency( | ||
| care_username: str, month: str, db: Session = Depends(get_db) | ||
| ): | ||
| """ | ||
| 보νΈμ νμ΄μ§: μ°κ²°λ μ μ μ νλ¬κ° κ°μ λΉλμ μ§κ³ (CareService λ΄λΆ λ‘μ§ μ¬μ©) | ||
| """ | ||
| care_service = CareService(db) | ||
| return care_service.get_emotion_monthly_frequency(care_username, month) | ||
| """보νΈμ: μ°κ²° μ μ μ μκ° λΉλ μ’ ν©λΆμ(OpenAI μΊμ + κΈ°μ‘΄ λΉλ κ²°κ³Ό)""" | ||
| from .services.analysis_service import get_frequency_result | ||
| try: | ||
| message = get_frequency_result(db, username=care_username, is_care=True) | ||
| from .care_service import CareService | ||
| care_service = CareService(db) | ||
| base = care_service.get_emotion_monthly_frequency(care_username, month) | ||
| frequency = base.get("frequency", {}) if base.get("success") else {} | ||
| return FrequencyAnalysisCombinedResponse(message=message, frequency=frequency) | ||
| except Exception as e: | ||
| raise HTTPException(status_code=400, detail=f"λΆμ μ€ν¨: {str(e)}") | ||
|
Comment on lines
+544
to
+558
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Care μλν¬μΈνΈμλ λμΌν μμΈ μ²λ¦¬ μ΄μ μμΈ μ ν κ΅¬λΆ λ° μμΈ μ²΄μ΄λ λ¬Έμ κ° λμΌνκ² μ‘΄μ¬ν©λλ€. Lines 365-376μμ μ μν μμ μ¬νμ μ΄ μλν¬μΈνΈμλ μ μ©νμΈμ. π§° Toolsπͺ Ruff (0.14.3)546-546: Do not perform function call (B008) 557-557: Do not catch blind exception: (BLE001) 558-558: Within an (B904) 558-558: Use explicit conversion flag Replace with conversion flag (RUF010) π€ Prompt for AI Agents |
||
|
|
||
| @care_router.get("/users/voices/analyzing/weekly") | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| @care_router.get("/users/voices/analyzing/weekly", response_model=WeeklyAnalysisCombinedResponse) | ||
| async def get_emotion_weekly_summary( | ||
| care_username: str, | ||
| month: str, | ||
| week: int, | ||
| db: Session = Depends(get_db) | ||
| ): | ||
| """보νΈμνμ΄μ§ - μ°κ²°μ μ μ/μ£Όμ°¨λ³ μμΌ top κ°μ ν΅κ³""" | ||
| care_service = CareService(db) | ||
| return care_service.get_emotion_weekly_summary(care_username, month, week) | ||
| """보νΈμ: μ°κ²° μ μ μ μ£Όκ° μ’ ν©λΆμ(OpenAI μΊμ μ¬μ©)""" | ||
| from .services.analysis_service import get_weekly_result | ||
| try: | ||
| message = get_weekly_result(db, username=care_username, is_care=True) | ||
| # κΈ°μ‘΄ μ£Όκ° μμ½λ ν¨κ» μ 곡 | ||
| care_service = CareService(db) | ||
| weekly_result = care_service.get_emotion_weekly_summary(care_username, month, week) | ||
| weekly = weekly_result.get("weekly", []) if weekly_result.get("success") else [] | ||
| return WeeklyAnalysisCombinedResponse(message=message, weekly=weekly) | ||
| except Exception as e: | ||
| raise HTTPException(status_code=400, detail=f"λΆμ μ€ν¨: {str(e)}") | ||
|
Comment on lines
+566
to
+583
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Care weekly μλν¬μΈνΈμλ λμΌν μμΈ μ²λ¦¬ μ΄μ λͺ¨λ λΆμ μλν¬μΈνΈμμ μΌκ΄λκ² μμΈ μ²λ¦¬λ₯Ό κ°μ ν΄μΌ ν©λλ€. Lines 365-376μμ μ μν μμΈ μ²λ¦¬ ν¨ν΄μ μ΄ μλν¬μΈνΈμλ μ μ©νμΈμ. π§° Toolsπͺ Ruff (0.14.3)571-571: Do not perform function call (B008) 582-582: Do not catch blind exception: (BLE001) 583-583: Within an (B904) 583-583: Use explicit conversion flag Replace with conversion flag (RUF010) π€ Prompt for AI Agents |
||
|
|
||
|
|
||
|
|
||
|
|
||
| @care_router.get("/notifications", response_model=NotificationListResponse) | ||
| async def get_care_notifications(care_username: str, db: Session = Depends(get_db)): | ||
|
|
@@ -800,6 +835,22 @@ async def test_error(statusCode: int): | |
| detail=f"Invalid statusCode: {statusCode}. Only 400 or 500 are allowed." | ||
| ) | ||
|
|
||
|
|
||
| @test_router.post("/fcm/send") | ||
| async def test_fcm_send( | ||
| token: Optional[str] = None, | ||
| title: str = "Test Title", | ||
| body: str = "Test Body", | ||
| db: Session = Depends(get_db) | ||
| ): | ||
| """λ¨μΌ ν ν°μΌλ‘ FCM ν μ€νΈ μ μ‘ (SDKμμ λ°κΈλ°μ ν ν° μ¬μ©)""" | ||
| if not token: | ||
| raise HTTPException(status_code=400, detail="token is required") | ||
| from .services.fcm_service import FcmService | ||
| svc = FcmService(db) | ||
| result = svc.send_notification_to_tokens([token], title, body) | ||
| return {"success": True, "result": result} | ||
|
|
||
| # ---------------- router λ±λ‘ ---------------- | ||
| app.include_router(users_router) | ||
| app.include_router(care_router) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λͺ¨λ μμΈλ₯Ό 400μΌλ‘ μ²λ¦¬νλ κ²μ λΆμ μ ν©λλ€
OpenAI API νμμμ, λ°μ΄ν°λ² μ΄μ€ μ°κ²° μ€λ₯ λ± μλ² μΈ‘ λ¬Έμ λ 500 μλ¬λ‘ μ²λ¦¬λμ΄μΌ ν©λλ€. νμ¬λ λͺ¨λ μμΈλ₯Ό 400(ν΄λΌμ΄μΈνΈ μ€λ₯)μΌλ‘ λ°ννμ¬ ν΄λΌμ΄μΈνΈκ° μ¬μλ λ‘μ§μ μ¬λ°λ₯΄κ² ꡬννκΈ° μ΄λ ΅μ΅λλ€.
μμΈ μ νμ λ°λΌ μ μ ν μν μ½λλ₯Ό λ°ννλλ‘ μμ νμΈμ:
π§° Tools
πͺ Ruff (0.14.3)
366-366: Do not perform function call
Dependsin argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable(B008)
375-375: Do not catch blind exception:
Exception(BLE001)
376-376: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
376-376: Use explicit conversion flag
Replace with conversion flag
(RUF010)