How to run my view periodically till some end date?

一个人想着一个人 提交于 2020-07-10 06:45:47

问题


I have a model for running the scrapy tasks. Now the view returns scrapped results after some time. There is no any use of two fields search_frequency and scraping_end_date for now. This fields will be used to run the scrapy view till the scraping_end_date at the given search_frequency value.

For this problem How can I solve? Which approach will be better ? Is django only will be sufficient for this task? Any suggestions will be helpful.

my model looks like this

class Task(models.Model):
    task_status = (
        (0, 'running'),
        (1, 'running'),
        (2, 'completed'),
    )

    FREQUENCY = (
        ('1', '1 hrs'),
        ('2', '2 hrs'),
        ('5', '5 hrs'),
        ('10', '10 hrs'),
        ('24', '24 hrs'),
    )
    
    name = models.CharField(max_length=255)
    scraping_end_date = models.DateField(null=True, blank=True)
    status = models.IntegerField(choices=task_status)
    created_by = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True)
    search_frequency = models.CharField(max_length=5, null=True, blank=True, choices=FREQUENCY)
    domain = models.URLField()

来源:https://stackoverflow.com/questions/62753171/how-to-run-my-view-periodically-till-some-end-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!