def put(self, id):
        try:
            data = request.get_json()
            TaskService.updateTask(data=data, id=id)
            return {"result": "task updated successfully"}

        except Exception as e:
            return {"error": e.message}
 def delete(self, id):
     try:
         task = TaskService.getTask(id)
         if task is not None:
             TaskService.deleteTask(task)
             return {"result": 'task deleted successfully'}
         raise Exception('task not found')
     except Exception as e:
         return {"error", e.message}
    def post(self):
        try:
            data = request.get_json()

            task = TaskService.addTask(data=data)
            return task.serialize
        except KeyError as e:
            return {"error": 'the ' + e.message + ' is required'}
Beispiel #4
0
factorRepository = FactorRepository(factorMongoDataSource, factorDartMongoDataSource, factorFileDataSource)
repositories = {
    "crawlerRepository": crawlerRepository,
    "tasksRepository": tasksRepository,
    "stockRepository": stockRepository,
    "factorRepository": factorRepository
}

# SCHEDULER
taskScheduler = TaskScheduler(stockMongoDataSource.client)

# SERVICE
userService = UserService()
stockService = StockService(stockRepository, tasksRepository, crawlerRepository)
factorService = FactorService(manager, factorRepository, tasksRepository, crawlerRepository, None)
taskService = TaskService(manager, tasksRepository, taskScheduler, factorService, stockService, crawlerRepository)
factorService.taskService = taskService


taskSocketRouter = TaskSocketRouter(taskService, manager)
factorSocketRouter = FactorSocketRouter(factorService, manager)
stockSocketRouter = StockSocketRouter(stockService, manager)


locator.register(manager)
locator.register(tasksRepository)
locator.register(crawlerRepository)
locator.register(tasksRepository)
locator.register(factorRepository)
locator.register(userService)
locator.register(taskService)
 def get(self):
     tasks = TaskService.getTasks()
     return [item.serialize for item in tasks]
 def get(self, id):
     return TaskService.getTask(id).serialize, 201
 def delete(self):
     tasks = TaskService.getTasks()
     for task in tasks:
         TaskService.deleteTask(task)
     return {"result": 'done'}