Query the users who do not login recently (90 days).
        and not send email (120 days).
        time_model: num * month * hours * minite * second
        time_login: 3 * 30 * 24 * 60 * 60
        time_email: 4 * 30 * 24 * 60 * 60
6748
def query_nologin():
        '''
        
        '''
        time_now = tools.timestamp()
        return TabMember.select().where(
            ((time_now - TabMember.time_login) > 7776000)
            & ((time_now - TabMember.time_email) > 10368000)
        )
1074449
def query_recent_most(num=8, recent=30):
        '''
        
        '''
        time_that = int(time.time()) - recent * 24 * 3600
        return TabPost.select().where(
            TabPost.time_update > time_that
        ).order_by(
            TabPost.view_count.desc()
        ).limit(num)
359155
def find_user(self, username=None, email=None):
        
        if username:
            return (
                self.get_session.query(self.user_model)
                .filter(func.lower(self.user_model.username) == func.lower(username))
                .first()
            )
        elif email:
            return (
                self.get_session.query(self.user_model).filter_by(email=email).first()
            )
518830
def wherenot(self, fieldname, value):
        
        return self.where(fieldname, value, negate=True)
251356
def get_reservations(self, email, date, timeout=None):
        
        try:
            resp = self._request("GET", "/1.1/space/bookings?email={}&date={}&limit=100".format(email, date), timeout=timeout)
        except resp.exceptions.HTTPError as error:
            raise APIError("Server Error: {}".format(error))
        except requests.exceptions.ConnectTimeout:
            raise APIError("Timeout Error")
        return resp.json()
980888
def query_by_account(self, account_id, end_time=None, start_time=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - account_id
        """ID"""
        path["account_id"] = account_id

        # OPTIONAL - start_time
        """The beginning of the time range from which you want events."""
        if start_time is not None:
            params["start_time"] = start_time

        # OPTIONAL - end_time
        """The end of the time range from which you want events."""
        if end_time is not None:
            params["end_time"] = end_time

        self.logger.debug("GET /api/v1/audit/authentication/accounts/{account_id} with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/audit/authentication/accounts/{account_id}".format(**path), data=data, params=params, no_data=True)
187513
def users(time_unit, start, duration)
      start = start.strftime(TIME_FORMAT[time_unit.downcase.to_sym])
      duration = build_duration(time_unit.downcase.to_sym, duration)
      params = {
        time_unit: time_unit.upcase,
        start: start,
        duration: duration
      }
      url = base_url + '/users'
      Http::Client.get(@jpush, url, params: params)
    end
488238
def query_dated(num=8, kind='1'):
        '''
        
        '''
        return TabPost.select().where(
            TabPost.kind == kind
        ).order_by(
            TabPost.time_update.asc()
        ).limit(num)
39196
def forgotten_pw(new_user=False):
    """"""
    email = request.form.get("email", "").lower()

    action = request.form.get("action")
    if action == "cancel":
        return redirect(url_for("login.login_form"))

    if not email:
        flash(_("You must provide your email address."), "error")
        return render_template("login/forgotten_password.html")

    try:
        user = User.query.filter(
            sql.func.lower(User.email) == email, User.can_login == True
        ).one()
    except NoResultFound:
        flash(
            _("Sorry, we couldn't find an account for " "email '{email}'.").format(
                email=email
            ),
            "error",
        )
        return render_template("login/forgotten_password.html"), 401

    if user.can_login and not user.password:
        user.set_password(random_password())
        db.session.commit()

    send_reset_password_instructions(user)
    flash(
        _("Password reset instructions have been sent to your email address."), "info"
    )

    return redirect(url_for("login.login_form"))
507168
def count_emails(self, conditions={}):
        
        url = self.EMAILS_COUNT_URL + "?"

        for key, value in conditions.items():
            if key is 'ids':
                value = ",".join(value)

            url += '&%s=%s' % (key, value)

        connection = Connection(self.token)
        connection.set_url(self.production, url)
        connection.set_url(self.production, url)

        return connection.get_request()
8291
def check_db_for_missing_notifications():
    """"""
    config = dallinger.config.get_config()
    participants = Participant.query.filter_by(status="working").all()
    reference_time = datetime.now()

    run_check(participants, config, reference_time)
681767
def do_login():
    

    dt_filter = lambda x: x >= datetime.utcnow() - timedelta(seconds=60)
    app.config['AUTH_ATTEMPTS'] = filter(dt_filter, app.config['AUTH_ATTEMPTS'])

    if len(app.config['AUTH_ATTEMPTS']) > app.config['AUTH_RATE_LIMIT']:
        return redirect(url_for('login',
                                alert="Rate limit exceeded. Try again in 60 seconds."))

    if request.form.get('password') == app.config['APP_PASSWORD']:
        login_user(SingleAuthUser)
        return redirect('/')

    app.config['AUTH_ATTEMPTS'].append(datetime.utcnow())
    return redirect(url_for('login', alert="Incorrect password."))
518250
def lately(self, count=15):
        
        excludes = '|'.join(('*.pyc', '*.swp', '*.bak', '*~'))
        cmd = ('''find . -printf "%%T@ %%p\\n" '''
               '''| egrep -v '%s' '''
               '''| sort -n '''
               '''| tail -n %d''') % (excludes, count)
        op = self.sh(cmd, shell=True)
        for l in op.split('\n'):
            l = l.strip()
            if not l:
                continue
            mtime, fname = l.split(' ', 1)
            mtime = datetime.datetime.fromtimestamp(float(mtime))
            mtimestr = dtformat(mtime)
            yield mtimestr, fname
124584
def update_time_login(u_name):
        '''
        
        '''
        entry = TabMember.update(
            time_login=tools.timestamp()
        ).where(
            TabMember.user_name == u_name
        )
        entry.execute()
326864
def login(self, email=None, password=None, app_id=None, api_key=None):
        
        session_token = self.api.user_get_session_token(
            app_id=app_id, email=email, password=password, api_key=api_key)

        # install session token back into api client
        self.api.session = session_token
1138534
def user(self, extra_params=None):
        
        if self.get('assigned_to_id', None):
            users = self.space.users(
                id=self['assigned_to_id'],
                extra_params=extra_params
            )
            if users:
                return users[0]
761096
def find_users_by_email_starting_with(email_prefix=None, cursor=None, page_size=30):
    
    email_prefix = email_prefix or ''

    return ModelSearchCommand(MainUser.query_email_starts_with(email_prefix),
                              page_size, cursor, cache_begin=None)