示例#1
0
def report_generate(filtered=True):

    html_dir = "./www"

    conn = lite.connect("jobs.db")
    cursor = conn.cursor()

    if (filtered):
        sql = "SELECT * FROM offers WHERE company not IN (SELECT company FROM blacklist) ORDER BY date_pub DESC"
        report = open(os.path.join(html_dir, 'report_filtered.html'), 'w')
    else:
        sql = "SELECT * FROM offers ORDER BY date_pub DESC"
        report = open(os.path.join(html_dir, 'report_full.html'), 'w')
    
    #sql = "SELECT * FROM offers WHERE company IN (SELECT company FROM blacklist) ORDER BY date_pub DESC"
    cursor.execute(sql)
    data = cursor.fetchall()

    report.write("<html><head>")
    report.write("<link href=\"./bootstrap.css\" rel=\"stylesheet\">")
    report.write("<style>table{border:1px solid black; font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;}</style>")
    report.write("<meta http-equiv=\"Content-type\" content=\"text/html\"; charset=\"utf-8\"></head>")
    report.write("<body><table class=\"table table-bordered\">")

    report.write("<p>There are <b>%s</b> offers</p>" %(len(data)))
    report.write("<p><a href=\"report_filtered.html\">Filtered Offers</a> - <a href=\"report_full.html\">All offers</a></p>")

    report.write("<thead>")
    report.write("<tr>")
    report.write("<th>Pubdate</th>")
    report.write("<th>Source</th>")
    report.write("<th>Title</th>")
    report.write("<th>Location</th>")
    report.write("<th>Type</th>")
    report.write("<th>Company</th>")
    report.write("<th>Contract</th>")
    report.write("<th>Salary</th>")
    report.write("</tr>")
    report.write("</thead>")

    for row in data:
        offer = Offer()
        offer.load(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12])
        report.write("<tr>")
        report.write('<td>' + offer.date_pub.strftime('%Y-%m-%d') + '</a></td>')
        report.write('<td>' + offer.src + '</td>')
        report.write('<td><a href="'+offer.url+'">' + offer.title + '</a></td>')
        report.write('<td>' + offer.location + '</td>')
        #report.write('<td><span class="label label-important">SSII</span></td>')
        report.write('<td><span class="label label-success">noSSII</span></td>')
        report.write('<td>' + offer.company + '</td>')

        if (offer.contract == ur'CDI' or offer.contract == ur'CDI (Cab/recrut)'):
            report.write('<td><span class="label label-success">'+ offer.contract +'</span></td>')
        elif (offer.contract == ur'CDD'):
            report.write('<td><span class="label label-warning">'+ offer.contract +'</span></td>')
示例#2
0
def report_generate(filtered=True):

    html_dir = "./www"

    conn = lite.connect("jobs.db")
    cursor = conn.cursor()

    sql_filtered = "SELECT * FROM offers WHERE company not IN (SELECT company FROM blacklist) ORDER BY date_pub DESC"
    sql_full = "SELECT * FROM offers ORDER BY date_pub DESC"

    cursor.execute(sql_filtered)
    data_filtered = cursor.fetchall()
    count_filtered = len(data_filtered)

    cursor.execute(sql_full)
    data_full = cursor.fetchall()
    count_full = len(data_full)

    #sql = "SELECT * FROM offers WHERE company IN (SELECT company FROM blacklist) ORDER BY date_pub DESC"

    # sql = "SELECT count(*)FROM offers"
    # cursor.execute(sql)
    # count = cursor.fetchone()[0]

    if (filtered):
        report = open(os.path.join(html_dir, 'report_filtered.html'), 'w')
        data = data_filtered
    else:
        report = open(os.path.join(html_dir, 'report_full.html'), 'w')
        data = data_full

    report.write("<html><head>")
    report.write("<link href=\"./bootstrap.css\" rel=\"stylesheet\">")
    report.write("<link href=\"./bootstrap-responsive.css\" rel=\"stylesheet\">")
    report.write("<style>table{font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;}</style>")
    report.write("<meta http-equiv=\"Content-type\" content=\"text/html\"; charset=\"utf-8\"></head>")
    report.write("<body>")

    report.write("<center><p><a href=\"report_filtered.html\">%s filtered offers (%.2f%%)</a>" %(count_filtered, 100*(float)(count_filtered)/count_full))
    report.write(" - %s blacklisted offers (%.2f%%)" %(count_full-count_filtered, 100*(float)(count_full-count_filtered)/count_full) )
    report.write(" - <a href=\"report_full.html\">All %s offers</a>" %(count_full) )
    report.write(" - <a href=\"statistics.html\">Statistics</a></p></center>" )

    report.write("<table class=\"table table-condensed\">")
    report.write("<thead>")
    report.write("<tr>")
    report.write("<th>Pubdate</th>")
    report.write("<th>Type</th>")
    report.write("<th>Title</th>")
    report.write("<th>Company</th>")
    report.write("<th>Location</th>")
    report.write("<th>Contract</th>")
    report.write("<th>Salary</th>")
    report.write("<th>Source</th>")
    report.write("</tr>")
    report.write("</thead>")

    s_date = ''

    for row in data:
        offer = Offer()
        offer.load(row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12])

        if (s_date != offer.date_pub.strftime('%Y-%m-%d')):
            s_date = offer.date_pub.strftime('%Y-%m-%d')
            report.write('<tr class=\"error\">');
            report.write('<td></td>');
            report.write('<td></td>');
            report.write('<td></td>');
            report.write('<td></td>');
            report.write('<td></td>');
            report.write('<td></td>');
            report.write('<td></td>');
            report.write('<td></td>');
            report.write('</tr>');

        report.write("<tr>")
        report.write('<td>' + offer.date_pub.strftime('%Y-%m-%d') + '</a></td>')
        report.write('<td><span class="label label-success">noSSII</span></td>')
        report.write('<td><a href="'+offer.url+'">' + offer.title + '</a></td>')
        report.write('<td>' + offer.company + '</td>')
        report.write('<td>' + offer.location + '</td>')
        #report.write('<td><span class="label label-important">SSII</span></td>')

        if (offer.contract == ur'CDI' or offer.contract == ur'CDI (Cab/recrut)'):
            report.write('<td><span class="label label-success">'+ offer.contract +'</span></td>')
        elif (offer.contract[:3] == ur'CDD'):
            report.write('<td><span class="label label-warning">'+ offer.contract +'</span></td>')
示例#3
0
def report_generate(filtered=True):

    html_dir = "./www"

    conn = lite.connect("jobs.db")
    cursor = conn.cursor()

    sql_filtered = "SELECT * FROM offers WHERE company not IN (SELECT company FROM blacklist) ORDER BY date_pub DESC"
    sql_full = "SELECT * FROM offers ORDER BY date_pub DESC"

    cursor.execute(sql_filtered)
    data_filtered = cursor.fetchall()
    count_filtered = len(data_filtered)

    cursor.execute(sql_full)
    data_full = cursor.fetchall()
    count_full = len(data_full)

    #sql = "SELECT * FROM offers WHERE company IN (SELECT company FROM blacklist) ORDER BY date_pub DESC"

    # sql = "SELECT count(*)FROM offers"
    # cursor.execute(sql)
    # count = cursor.fetchone()[0]

    if (filtered):
        report = open(os.path.join(html_dir, 'report_filtered.html'), 'w')
        data = data_filtered
    else:
        report = open(os.path.join(html_dir, 'report_full.html'), 'w')
        data = data_full

    report.write("<html><head>")
    report.write("<link href=\"./bootstrap.css\" rel=\"stylesheet\">")
    report.write(
        "<link href=\"./bootstrap-responsive.css\" rel=\"stylesheet\">")
    report.write(
        "<style>table{font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;}</style>"
    )
    report.write(
        "<meta http-equiv=\"Content-type\" content=\"text/html\"; charset=\"utf-8\"></head>"
    )
    report.write("<body>")

    report.write(
        "<center><p><a href=\"report_filtered.html\">%s filtered offers (%.2f%%)</a>"
        % (count_filtered, 100 * (float)(count_filtered) / count_full))
    report.write(" - %s blacklisted offers (%.2f%%)" %
                 (count_full - count_filtered, 100 *
                  (float)(count_full - count_filtered) / count_full))
    report.write(" - <a href=\"report_full.html\">All %s offers</a>" %
                 (count_full))
    report.write(" - <a href=\"statistics.html\">Statistics</a></p></center>")

    report.write("<table class=\"table table-condensed\">")
    report.write("<thead>")
    report.write("<tr>")
    report.write("<th>Pubdate</th>")
    report.write("<th>Type</th>")
    report.write("<th>Title</th>")
    report.write("<th>Company</th>")
    report.write("<th>Location</th>")
    report.write("<th>Contract</th>")
    report.write("<th>Salary</th>")
    report.write("<th>Source</th>")
    report.write("</tr>")
    report.write("</thead>")

    s_date = ''

    for row in data:
        offer = Offer()
        offer.load(row[0], row[1], row[2], row[3], row[4], row[5], row[6],
                   row[7], row[8], row[9], row[10], row[11], row[12])

        if (s_date != offer.date_pub.strftime('%Y-%m-%d')):
            s_date = offer.date_pub.strftime('%Y-%m-%d')
            report.write('<tr class=\"error\">')
            report.write('<td></td>')
            report.write('<td></td>')
            report.write('<td></td>')
            report.write('<td></td>')
            report.write('<td></td>')
            report.write('<td></td>')
            report.write('<td></td>')
            report.write('<td></td>')
            report.write('</tr>')

        report.write("<tr>")
        report.write('<td>' + offer.date_pub.strftime('%Y-%m-%d') +
                     '</a></td>')
        report.write(
            '<td><span class="label label-success">noSSII</span></td>')
        report.write('<td><a href="' + offer.url + '">' + offer.title +
                     '</a></td>')
        report.write('<td>' + offer.company + '</td>')
        report.write('<td>' + offer.location + '</td>')
        #report.write('<td><span class="label label-important">SSII</span></td>')

        if (offer.contract == ur'CDI'
                or offer.contract == ur'CDI (Cab/recrut)'):
            report.write('<td><span class="label label-success">' +
                         offer.contract + '</span></td>')
        elif (offer.contract[:3] == ur'CDD'):
            report.write('<td><span class="label label-warning">' +
                         offer.contract + '</span></td>')