<commit_before>from gitmostwanted.models.repo import Repo, RepoStars
from gitmostwanted.app import app, db, celery
from gitmostwanted.services import bigquery
from gitmostwanted.lib.bigquery.job import Job
from datetime import datetime, timedelta
from time import sleep


def results_of(j: Job):
    while not j.complete:
        app.logger.debug('The job is not complete, waiting...')
        sleep(10)
    return j.results


@celery.task()
def stars_mature(num_days):
    date_from = (datetime.now() + timedelta(days=num_days * -1)).strftime('%Y-%m-%d')
    service = bigquery.instance(app)
    query = """
        SELECT
            COUNT(1) AS stars, YEAR(created_at) AS y, DAYOFYEAR(created_at) AS doy
        FROM
            TABLE_DATE_RANGE(
                githubarchive:day.events_, TIMESTAMP('{date_from}'), CURRENT_TIMESTAMP()
            )
        WHERE repo.id = {id} AND type = 'WatchEvent'
        GROUP BY y, doy
    """
    jobs = []<commit_msg>Improve the ranking logic, add forks, refs #127<commit_after>from gitmostwanted.models.repo import Repo, RepoStars
from gitmostwanted.app import app, db, celery
from gitmostwanted.services import bigquery
from gitmostwanted.lib.bigquery.job import Job
from datetime import datetime, timedelta
from time import sleep


def results_of(j: Job):
    while not j.complete:
        app.logger.debug('The job is not complete, waiting...')
        sleep(10)
    return j.results


@celery.task()
def stars_mature(num_days):
    date_from = (datetime.now() + timedelta(days=num_days * -1)).strftime('%Y-%m-%d')
    service = bigquery.instance(app)
    query = """
        SELECT
            COUNT(1) AS stars, YEAR(created_at) AS y, DAYOFYEAR(created_at) AS doy
        FROM
            TABLE_DATE_RANGE(
                githubarchive:day.events_, TIMESTAMP('{date_from}'), CURRENT_TIMESTAMP()
            )
        WHERE repo.id = {id} AND type IN ('WatchEvent', 'ForkEvent')
        GROUP BY y, doy
    """
    jobs = []
{'fraction_non_alphanumeric': 0.11082995951417005, 'fraction_numerical': 0.005566801619433198, 'mean_word_length': 2.961923847695391, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '648425', 'n_tokens_mistral': 656, 'n_tokens_neox': 616, 'n_words': 167}