SQL query: Posts, Tag, E DATA

in #sql-ptbr3 years ago (edited)
Authored by @Silva

Sql server test

SELECT *
FROM DBHive.dbo.TxComments
WHERE parent_permlink = 'sql-ptbr' AND parent_author = '' AND [timestamp] >= Convert(datetime, '2020-11-27' ) ;

Como pegar somente posts recentes usando o hivesql:

SELECT author, permlink, title, created, body_language FROM DBHive.dbo.Comments WHERE parent_author = '' AND created >= Convert(datetime, '2021-06-02' );

Baixe em csv e converta pra json usando o https://csvjson.com/csv2json

Abrindo o Json usando o nodejs e filtrar o idioma somente em portugues:

const fs = require('fs');
let rawdata = fs.readFileSync('csvjson.json');
let datatop = JSON.parse(rawdata);

var data = [{}]

for (const index in datatop) {   
    if(datatop[index]['body_language'][0]){
        if(datatop[index]['body_language'][0]['language'] === 'pt'){
            if(datatop[index]['body_language'][0]['confidence'] > 5.0){
                console.log(datatop[index]['body_language'][0]['language'] + ' ' + index ) 
                data.push(datatop[index])
            }
        }
        else if(datatop[index]['body_language'][1]){ 
            if(datatop[index]['body_language'][1]['language'] === 'pt'){
                    if(datatop[index]['body_language'][1]['confidence'] > 5.0){
                        console.log(datatop[index]['body_language'][1]['language'] + ' ' + index ) 
                        data.push(datatop[index])
                    }
                }
        }
        else if(datatop[index]['body_language'][2]){ 
            if(datatop[index]['body_language'][2]['language'] === 'pt'){
                    if(datatop[index]['body_language'][2]['confidence'] > 5.0){
                    console.log(datatop[index]['body_language'][2]['language'] + ' ' + index ) 
                    data.push(datatop[index])
                    }
                }
        }
    }
    else{}
}

var newData1 = JSON.stringify(data);
fs.writeFile('csvjson1.json', newData1, err => {
    if(err) throw err;
    
    console.log("New data added");
});

Indice de Posts

Sort:  

Congratulations @sm-silva! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You published more than 30 posts. Your next target is to reach 40 posts.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP