Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mtn script #169

Merged
merged 1 commit into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading