Creation of a "trusted list" for the system of checking the uniqueness of posts on NodeJs

in CampusConnect2 years ago

trusted list on NODEJS.png

I am working on a system for checking posts for their uniqueness. This is important because it allows you to identify copied text without citing sources. This means improving the quality of content in .STEEMIT

In this post, I publish one of the implemented tasks to finalize this system.

First of all I create table in MySql database

Script for create table.

//CREATE DATABASE [IF NOT EXISTS] имя_базы_даных;
const mysql = require("mysql2");
const steem = require('steem');
const fs = require("fs");    
var settings = require('./config.js');

let body3R = '';
let num_day = settings.num_day;
let bd_name = settings.bd_name;
let hive_name = settings.hive_name;
let url_post = settings.url_post;
let password_mysql = settings.password_mysql;
let user_mysql = settings.user_mysql;
let title_name = settings.title_name;
let image_list = settings.image_list;

config = {
  host: "localhost",
  user: user_mysql,
  database: bd_name,
  password: password_mysql
}

const connection = mysql.createConnection(config);

let sql3 = `create database ${bd_name}`;
console.log(sql3);                       

connection.query(sql3, function(err, results) {
if(err) console.log(err);
else console.log("Таблица создана");
});

let sql = `create table if not exists ${bd_name}.trusted( id int primary key auto_increment, author varchar(255) UNIQUE KEY)`;
console.log(sql);                        

connection.query(sql, function(err, results) {
if(err) console.log(err);
else console.log("Таблица создана");
});

let sql2 = `create table if not exists ${bd_name}.post_number_all( id int primary key auto_increment, number int)`;
console.log(sql2);                       

connection.query(sql2, function(err, results) {
if(err) console.log(err);
else console.log("Таблица создана");
});

const sql4 = `INSERT INTO ${bd_name}.post_number_all(id, number) VALUES('1','0')`;
console.log(sql4);                       
                                 
connection.query(sql4, function(err, results) {
if(err) console.log(err);
else console.log("Таблица создана");
});

connection.end();

Script for indicate trusted author in list of all posts.

const mysql = require("mysql2");
const steem = require('steem');
const fs = require("fs");    
var settings = require('./config.js');

let body3R = '';
let num_day = settings.num_day;
let bd_name = settings.bd_name;
let hive_name = settings.hive_name;
let url_post = settings.url_post;
let url_ok = settings.url_ok;
let password_mysql = settings.password_mysql;
let user_mysql = settings.user_mysql;
let title_name = settings.title_name;
let image_list = settings.image_list;
let moderators_list = settings.moderators_list;
let wifkey = settings.wifkey;
let votey = settings.votey;

config = {
  host: "localhost",
  user: user_mysql,
  database: bd_name,
  password: password_mysql
}

var d = new Date(); // Today!
d.setDate(d.getDate()-num_day); // Yesterday!
d = d.toJSON().split("T")[0];
d = d.replace(/-/gi, '');
        
const connection = mysql.createConnection(config);

        var d = new Date(); // Today!
        d.setDate(d.getDate()-num_day); // Yesterday!
        d = d.toJSON().split("T")[0];
        d = d.replace(/-/gi, '');
                        
        let mytable_p = 'p'+d;

        const sql = `SELECT * FROM allposts ORDER BY length DESC`;

        connection.query(sql,  function(err, results) 
        {
            len = results.length;
            for (yyy = 0; yyy < len; yyy++) 
            {
                const sql = `SELECT * FROM trusted WHERE author = '${results[yyy].author}'`;
                console.log(sql);
                console.log(yyy);

                connection.query(sql,  function(err, results)
                {

                    if (results[0])
                    {   
                        console.log('считаю что найдено!');
                        console.log(results[0].author);

                        const sql8 = `UPDATE allposts SET percent='777' WHERE author = '${results[0].author}' LIMIT 1000`;
                                                console.log(sql8);

                        connection.query(sql8,function(err, results) {
                        if(err) console.log(err);
                        });
                    }
                });
            }
        });
   
   
                    

Thank you for your attention.
Have a nice day!