#!/usr/bin/python # -*- coding=utf-8 -*- # @Create Time: 2024-02-21 14:04:06 # @Last Modified time: 2024-02-26 15:11:01 from datetime import datetime import requests from flask import current_app from flask_apscheduler import APScheduler from .models import Record scheduler = APScheduler() def dataAnalyze(): with scheduler.app.app_context(): redis_store = current_app.redis print(datetime.now().strftime('%Y-%m-%d %H:%M:%S')) for key in redis_store.keys(): if 'size' in key and int(redis_store.get(key)) > 1000: response = requests.get(f'http://localhost:7788/analyse?user_id={key[:-5]}') if response.status_code == 200: redis_store.set(key, 0) # print(Record.query.filter_by().count()) def genHeatMap(): with scheduler.app.app_context(): redis_store = current_app.redis for key in redis_store.keys(): if 'size' in key and int(redis_store.get(key)) > 10000: response = requests.get(f'http://localhost:7788/heatmap?user_id={key[:-5]}') if response.status_code == 200: redis_store.set(key, 0)