Skip to content

Commit

Permalink
feat: add mtn script
Browse files Browse the repository at this point in the history
  • Loading branch information
ddio committed Dec 31, 2023
1 parent 7103136 commit d6e2c5a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions twrh-dataset/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ crawler/settings.py
*.log
*.csv
rental_house.json
devop
datas/*.zip
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)
8 changes: 8 additions & 0 deletions twrh-dataset/remove-duplicated-task.sh
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

0 comments on commit d6e2c5a

Please sign in to comment.