Subversion Repositories SmartDukaan

Rev

Rev 17330 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17330 Rev 17341
Line 55... Line 55...
55
    and datediff(curdate(),u.created)<7
55
    and datediff(curdate(),u.created)<7
56
    group by u.user_id,skuBundleId; 
56
    group by u.user_id,skuBundleId; 
57
"""
57
"""
58
 
58
 
59
REPLACE_QUERY="""
59
REPLACE_QUERY="""
60
REPLACE INTO newuserlinkssegmentation( user_id, brand, source,category_id, count, weight,modified) 
60
REPLACE INTO newuserlinkssegmentation( user_id, brand, source,category_id, count, weight,created,modified) 
61
SELECT user_id, brand, source,category_id, count, weight,created
61
SELECT user_id, brand, source,category_id, count, weight,created,now()
62
FROM newuserlinkssegmentation7days
62
FROM newuserlinkssegmentation7days
63
WHERE user_id =%s and brand=%s and category_id=%s and source=%s
63
WHERE user_id =%s and brand=%s and category_id=%s and source=%s
64
"""
64
"""
65
 
65
 
66
 
66
 
Line 340... Line 340...
340
    sources = ['product_view','clicks','filters','orders','preferences']
340
    sources = ['product_view','clicks','filters','orders','preferences']
341
    datesql= "select distinct brand from newuserlinkssegmentation where user_id=%s and brand=%s and category_id=%s" 
341
    datesql= "select distinct brand from newuserlinkssegmentation where user_id=%s and brand=%s and category_id=%s" 
342
    conn = getDbConnection()
342
    conn = getDbConnection()
343
    cursor = conn.cursor()
343
    cursor = conn.cursor()
344
    cursor.execute(datesql,(userId,brand,category))
344
    cursor.execute(datesql,(userId,brand,category))
345
    result = cursor.fetchone()
345
    result = cursor.fetchall()
346
    print 'Result in Check user for update',result
346
    print 'Result in Check user for update',result
347
    if len(result)==0:
347
    if len(result)==0:
348
        insertNewUserLinkDetails(userId,brand,category)
348
        insertNewUserLinkDetails(userId,brand,category)
349
    else:
349
    else:
350
        datesql= "select distinct source from newuserlinkssegmentation where user_id=%s and brand=%s and category_id=%s"
350
        datesql= "select distinct source from newuserlinkssegmentation where user_id=%s and brand=%s and category_id=%s"
351
        cursor.execute(datesql,(userId,result[0][0],category))
351
        cursor.execute(datesql,(userId,result[0][0],category))
352
        result = cursor.fetchall()
352
        newResult = cursor.fetchall()
-
 
353
        print 'Data for source',newResult
353
        for source in result:
354
        for source in newResult:
-
 
355
            print 'Source',source[0]
354
            userReplaceData(userId,brand,category, source)
356
            userReplaceData(userId,brand,category, source[0])
355
            sources.remove(source)
357
            sources.remove(source[0])
356
        for source in sources:
358
        for source in sources:
357
            insertNewUserLinkDetailsSourceWise(userId,brand,category, source)
359
            insertNewUserLinkDetailsSourceWise(userId,brand,category, source)
358
    conn.close()    
360
    conn.close()    
359
 
361
 
360
def userReplaceData(userId,brand,category,source):
362
def userReplaceData(userId,brand,category,source):