Widget: DCTList: Difference between revisions

From LINKS Community Center
Jump to: navigation, search
Eschmidt (talk | contribs)
No edit summary
Eschmidt (talk | contribs)
No edit summary
Line 177: Line 177:
         const FUNC_KEY = 'functions';
         const FUNC_KEY = 'functions';
         const DESC_KEY = 'description';
         const DESC_KEY = 'description';
       
        /** @type Map<string, { [DESC_KEY]: string, [FUNC_KEY]: string[] } */
        const functionsData = new Map();


         const hasFunction = (dctResult, subfunctions) => subfunctions.some(func => {
         const hasFunction = (dctResult, subfunctions) => subfunctions.some(func => {
Line 190: Line 193:
         const functionsQueryResults = functionsQueryResponse.query.results;
         const functionsQueryResults = functionsQueryResponse.query.results;
          
          
        const functionsData = new Map();
         Object.keys(functionsQueryResults).forEach(key => {
         Object.keys(functionsQueryResults).forEach(key => {
             const functionCategory = functionsQueryResults[key];
             const functionCategory = functionsQueryResults[key];
Line 202: Line 203:
                     [FUNC_KEY]: functionCategory.printouts[FUNC_KEY].map(subfunction => removePrefix(subfunction.fulltext))
                     [FUNC_KEY]: functionCategory.printouts[FUNC_KEY].map(subfunction => removePrefix(subfunction.fulltext))
                 }
                 }
             )
             );
         })
         });


         let test = Array.from(functionsData.values(), entry => entry[FUNC_KEY]).flat();
         const allFunctions = Array.from(functionsData.values(), entry => entry[FUNC_KEY]).flat();
        let qstr = test.join('|?')
        // console.log('Func result', test);
 
 
        const searchFunctions = [
            'Advanced search features',
            'Keyword search',
            'Hashtag search',
            'Keyword monitoring',
            'Hashtag monitoring',
            'Event monitoring',
            'Event notification'
        ];
        const postFunctions = [
            'Posting content',
            'Scheduling content',
            'Post time optimization',
            'Content library'
        ];
        const analysisFunctions = [
            'Text analysis',
            'Image analysis',
            'Video analysis',
            'Topic analysis',
            'Sentiment analysis',
            'Trend analysis'
        ];
        const metricsFunctions = [
            'Post metrics',
            'Profile or Site metrics',
            'Network metrics',
            'Follower metrics',
            'Audience metrics',
            'Competitor metrics'
        ];
        const reportFunctions = [
            'Filtering sorting searching',
            'Clustering Aggregation',
            'Visualization options',
            'PDF export'
        ];
        const collaborationFunctions = [
            'Multiuser',
            'Permission management',
            'Inbox workflow',
            'Approval workflows'
        ];
        const interoperabilityFunctions = [
            'Data export',
            'Third party tool integration',
            'API support'
        ];
        const metaFunctions = [
            'White Label',
            'GDPR compliant',
            'Historical data access',
            'Multiple accounts per platform'
        ];
 
        const dctQuery2 = '[[Category:Disaster Community Technology]]' +
                        '[[Is Archived::No]]' +
                        '|limit=500' +
                        '|?Image' +
                        '|?Data Sources' +
                        '|?' + qstr;
                    console.log('new len', dctQuery2.length)


         const dctQuery = '[[Category:Disaster Community Technology]]' +
         const dctQuery = '[[Category:Disaster Community Technology]]' +
Line 278: Line 213:
                         '|?Image' +
                         '|?Image' +
                         '|?Data Sources' +
                         '|?Data Sources' +
                         '|?' + searchFunctions.join('|?') +
                         '|?' + allFunctions.join('|?');
                        '|?' + postFunctions.join('|?') +
                        '|?' + analysisFunctions.join('|?') +
                        '|?' + metricsFunctions.join('|?') +
                        '|?' + reportFunctions.join('|?') +
                        '|?' + collaborationFunctions.join('|?') +
                        '|?' + interoperabilityFunctions.join('|?') +
                        '|?' + metaFunctions.join('|?');
 
                        console.log('current len', dctQuery.length)
 
        const dctQueryUrl = '/api.php?action=ask&format=json&query=' + encodeURIComponent(dctQuery);
        const dctResponse = await fetch(dctQueryUrl).then(response => response.json());
 
        const dctQueryUrl2 = '/api.php?action=ask&format=json&query=' + encodeURIComponent(dctQuery2);
        const dctResponse2 = await fetch(dctQueryUrl2).then(response => response.json());
 
        console.log('new res', dctResponse2.query.results)


         const results = dctResponse.query.results;
         const dctResponse = await fetch(getQueryUrl(dctQuery)).then(response => response.json());
         console.log('current res', results)
         console.log(dctResponse.query.results)
         const dctList = Object.getOwnPropertyNames(results).map(dctKey => {
         const dctList = Object.keys(dctResponse.query.results).map(dctKey => {
            const dctResult = dctResponse.query.results[dctKey];


             /** @type {DCT} */
             /** @type {DCT} */
             const dct = {};
             const dct = {};
            const dctResult = results[dctKey];
             dct.name = dctKey;
             dct.name = dctKey;
             dct.url = dctResult.fullurl;
             dct.url = dctResult.fullurl;
             dct.dataSources = dctResult.printouts['Data Sources'].map(source => source.fulltext).sort();
             dct.dataSources = dctResult.printouts['Data Sources'].map(source => source.fulltext).sort();
             dct.logo = dctResult.printouts['Image'][0] ? getFilePath(dctResult.printouts['Image'][0].fulltext) : void 0;
             dct.logo = dctResult.printouts['Image'][0] ? getFilePath(dctResult.printouts['Image'][0].fulltext) : undefined;
             dct.functions = [];
             dct.functions = [];


             if (hasFunction(dctResult, searchFunctions)) dct.functions.push(FN_SEARCH);
             // functionsData.forEach((value, key) => {
             if (hasFunction(dctResult, postFunctions)) dct.functions.push(FN_POST);
            //    if (value[FUNC_KEY].some(func =>))
             if (hasFunction(dctResult, analysisFunctions)) dct.functions.push(FN_ANALYSIS);
            // });
             if (hasFunction(dctResult, metricsFunctions)) dct.functions.push(FN_METRICS);
 
             if (hasFunction(dctResult, reportFunctions)) dct.functions.push(FN_REPORT);
            // if (hasFunction(dctResult, searchFunctions)) dct.functions.push(FN_SEARCH);
             if (hasFunction(dctResult, collaborationFunctions)) dct.functions.push(FN_COLLAB);
             // if (hasFunction(dctResult, postFunctions)) dct.functions.push(FN_POST);
             if (hasFunction(dctResult, interoperabilityFunctions)) dct.functions.push(FN_INTEROP);
             // if (hasFunction(dctResult, analysisFunctions)) dct.functions.push(FN_ANALYSIS);
             if (hasFunction(dctResult, metaFunctions)) dct.functions.push(FN_META);
             // if (hasFunction(dctResult, metricsFunctions)) dct.functions.push(FN_METRICS);
             // if (hasFunction(dctResult, reportFunctions)) dct.functions.push(FN_REPORT);
             // if (hasFunction(dctResult, collaborationFunctions)) dct.functions.push(FN_COLLAB);
             // if (hasFunction(dctResult, interoperabilityFunctions)) dct.functions.push(FN_INTEROP);
             // if (hasFunction(dctResult, metaFunctions)) dct.functions.push(FN_META);


             return dct;
             return dct;

Revision as of 15:02, 30 August 2022

Development verstion of the DCT List.
Not ready for production!