-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ crawler/settings.py | |
*.log | ||
*.csv | ||
rental_house.json | ||
devop | ||
datas/*.zip |
23 changes: 23 additions & 0 deletions
23
twrh-dataset/django/crawlerrequest/management/commands/deduprequest.py
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,23 @@ | ||
"""Remove duplicated request""" | ||
from django.core.management.base import BaseCommand | ||
from django.db import connection | ||
|
||
SQL = """ | ||
delete from request_ts where id in ( | ||
select id from ( | ||
select | ||
min(id) as id, | ||
count(*) as n | ||
from request_ts | ||
group by year, month, day, (seed->>0) | ||
) | ||
as t where n > 1 | ||
); | ||
""" | ||
|
||
class Command(BaseCommand): | ||
help = 'Remove duplicated request' | ||
|
||
def handle(self, *args, **options): | ||
with connection.cursor() as cursor: | ||
cursor.execute(SQL) |
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,8 @@ | ||
#!/bin/bash | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
cd $DIR | ||
|
||
now=`date +'%Y.%m.%d.%H%M'` | ||
echo "------ $now ------" >> ../logs/deduprequest.log | ||
pipenv run python manage.py deduprequest >> ../logs/deduprequest.log |