@yrpri/api 9.0.103 → 9.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/active-citizen/controllers/activities.cjs +0 -174
- package/dist/active-citizen/controllers/news_feeds.cjs +0 -96
- package/dist/active-citizen/controllers/notifications.cjs +0 -243
- package/dist/active-citizen/controllers/recommendations.cjs +0 -280
- package/dist/active-citizen/engine/allOurIdeas/aiHelper.js +0 -204
- package/dist/active-citizen/engine/allOurIdeas/explainAnswersAssistant.js +0 -66
- package/dist/active-citizen/engine/allOurIdeas/iconGenerator.js +0 -38
- package/dist/active-citizen/engine/analytics/export_anon_community_activities.js +0 -334
- package/dist/active-citizen/engine/analytics/importer.js +0 -308
- package/dist/active-citizen/engine/analytics/manager.cjs +0 -377
- package/dist/active-citizen/engine/analytics/plausible/manager.cjs +0 -500
- package/dist/active-citizen/engine/analytics/statsCalc.cjs +0 -194
- package/dist/active-citizen/engine/analytics/utils.cjs +0 -369
- package/dist/active-citizen/engine/marketing/campaign.cjs +0 -90
- package/dist/active-citizen/engine/moderation/fraud/CreateFraudAuditReport.cjs +0 -313
- package/dist/active-citizen/engine/moderation/fraud/FraudBase.cjs +0 -239
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteBase.cjs +0 -211
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteEndorsements.cjs +0 -120
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePointQualities.cjs +0 -114
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePoints.cjs +0 -101
- package/dist/active-citizen/engine/moderation/fraud/FraudDeletePosts.cjs +0 -84
- package/dist/active-citizen/engine/moderation/fraud/FraudDeleteRatings.cjs +0 -15
- package/dist/active-citizen/engine/moderation/fraud/FraudGetBase.cjs +0 -133
- package/dist/active-citizen/engine/moderation/fraud/FraudGetEndorsements.cjs +0 -185
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPointQualities.cjs +0 -184
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPoints.cjs +0 -170
- package/dist/active-citizen/engine/moderation/fraud/FraudGetPosts.cjs +0 -109
- package/dist/active-citizen/engine/moderation/fraud/FraudGetRatings.cjs +0 -140
- package/dist/active-citizen/engine/moderation/fraud/FraudScannerNotifier.cjs +0 -279
- package/dist/active-citizen/engine/moderation/get_moderation_items.cjs +0 -386
- package/dist/active-citizen/engine/moderation/image_labeling/CommunityLabeling.cjs +0 -49
- package/dist/active-citizen/engine/moderation/image_labeling/GroupLabeling.cjs +0 -68
- package/dist/active-citizen/engine/moderation/image_labeling/ImageLabelingBase.cjs +0 -288
- package/dist/active-citizen/engine/moderation/image_labeling/PointLabeling.cjs +0 -33
- package/dist/active-citizen/engine/moderation/image_labeling/PostLabeling.cjs +0 -56
- package/dist/active-citizen/engine/moderation/perspective_api_client.cjs +0 -106
- package/dist/active-citizen/engine/moderation/process_moderation_items.cjs +0 -344
- package/dist/active-citizen/engine/moderation/toxicity_analysis.cjs +0 -810
- package/dist/active-citizen/engine/news_feeds/activity_and_item_index_definitions.cjs +0 -15
- package/dist/active-citizen/engine/news_feeds/generate_dynamically.cjs +0 -362
- package/dist/active-citizen/engine/news_feeds/generate_from_notifications.cjs +0 -268
- package/dist/active-citizen/engine/news_feeds/news_feeds_utils.cjs +0 -439
- package/dist/active-citizen/engine/notifications/emails_utils.cjs +0 -569
- package/dist/active-citizen/engine/notifications/generate_point_notifications.cjs +0 -233
- package/dist/active-citizen/engine/notifications/generate_post_notifications.cjs +0 -118
- package/dist/active-citizen/engine/notifications/generate_post_status_change_notifications.cjs +0 -41
- package/dist/active-citizen/engine/notifications/notifications_utils.cjs +0 -148
- package/dist/active-citizen/engine/notifications/point_delivery.cjs +0 -54
- package/dist/active-citizen/engine/notifications/post_delivery.cjs +0 -31
- package/dist/active-citizen/engine/notifications/process_delayed_notifications.cjs +0 -471
- package/dist/active-citizen/engine/notifications/process_general_notifications.cjs +0 -212
- package/dist/active-citizen/engine/old/exporters/categories_dataset.js +0 -153
- package/dist/active-citizen/engine/old/exporters/dataset_tools.js +0 -80
- package/dist/active-citizen/engine/old/exporters/sentiment_dataset.js +0 -157
- package/dist/active-citizen/engine/recommendations/events_importer.cjs +0 -139
- package/dist/active-citizen/engine/recommendations/events_manager.cjs +0 -212
- package/dist/active-citizen/engine/reports/add_points_to_sheet.cjs +0 -83
- package/dist/active-citizen/engine/reports/commonUtils.js +0 -75
- package/dist/active-citizen/engine/reports/common_utils.cjs +0 -740
- package/dist/active-citizen/engine/reports/docx_group_report.cjs +0 -596
- package/dist/active-citizen/engine/reports/xlsAllOurIdeasExport.js +0 -232
- package/dist/active-citizen/engine/reports/xls_community_users_report.cjs +0 -277
- package/dist/active-citizen/engine/reports/xls_group_report.cjs +0 -718
- package/dist/active-citizen/llms/baseChatBot.js +0 -183
- package/dist/active-citizen/llms/imageGeneration/chatGptImageGenerator.js +0 -56
- package/dist/active-citizen/llms/imageGeneration/collectionImageGenerator.js +0 -109
- package/dist/active-citizen/llms/imageGeneration/dalleImageGenerator.js +0 -84
- package/dist/active-citizen/llms/imageGeneration/fluxImageGenerator.js +0 -49
- package/dist/active-citizen/llms/imageGeneration/iImageGenerator.js +0 -1
- package/dist/active-citizen/llms/imageGeneration/imageProcessorService.js +0 -64
- package/dist/active-citizen/llms/imageGeneration/imagenImageGenerator.js +0 -107
- package/dist/active-citizen/llms/imageGeneration/s3Service.js +0 -110
- package/dist/active-citizen/llms/llmTranslation.js +0 -472
- package/dist/active-citizen/models/ac_activity.cjs +0 -216
- package/dist/active-citizen/models/ac_background_job.cjs +0 -109
- package/dist/active-citizen/models/ac_campaign.cjs +0 -97
- package/dist/active-citizen/models/ac_client_activity.cjs +0 -23
- package/dist/active-citizen/models/ac_delayed_notification.cjs +0 -43
- package/dist/active-citizen/models/ac_following.cjs +0 -43
- package/dist/active-citizen/models/ac_list.cjs +0 -68
- package/dist/active-citizen/models/ac_list_users.cjs +0 -19
- package/dist/active-citizen/models/ac_mute.cjs +0 -27
- package/dist/active-citizen/models/ac_news_feed_item.cjs +0 -57
- package/dist/active-citizen/models/ac_news_feed_processed_range.cjs +0 -59
- package/dist/active-citizen/models/ac_notification.cjs +0 -292
- package/dist/active-citizen/models/ac_translation_cache.cjs +0 -750
- package/dist/active-citizen/models/ac_watching.cjs +0 -31
- package/dist/active-citizen/scripts/analytics/setup_all_plausible_goals.cjs +0 -13
- package/dist/active-citizen/scripts/fix_old_delayed_notifications.js +0 -63
- package/dist/active-citizen/scripts/kue_status.js +0 -31
- package/dist/active-citizen/scripts/kue_watch_stuck_jobs.js +0 -24
- package/dist/active-citizen/scripts/translation_clear_language.js +0 -117
- package/dist/active-citizen/scripts/translation_delete.js +0 -27
- package/dist/active-citizen/scripts/translation_replace_text_from_url.js +0 -180
- package/dist/active-citizen/scripts/translation_update.js +0 -28
- package/dist/active-citizen/scripts/translations_list.js +0 -27
- package/dist/active-citizen/utils/airbrake.cjs +0 -17
- package/dist/active-citizen/utils/get_anonymous_system_user.cjs +0 -21
- package/dist/active-citizen/utils/i18n.cjs +0 -3
- package/dist/active-citizen/utils/logger.cjs +0 -25
- package/dist/active-citizen/utils/redisConnection.cjs +0 -29
- package/dist/active-citizen/utils/to_json.cjs +0 -9
- package/dist/active-citizen/utils/translation_cloning.cjs +0 -171
- package/dist/active-citizen/utils/translation_helpers.cjs +0 -534
- package/dist/active-citizen/utils/truncate_text.cjs +0 -21
- package/dist/active-citizen/utils/updateAllLocalesFromEn.js +0 -253
- package/dist/active-citizen/utils/updateLocaleFolders.js +0 -34
- package/dist/active-citizen/workers/activity.cjs +0 -189
- package/dist/active-citizen/workers/anonymizations.cjs +0 -734
- package/dist/active-citizen/workers/bulk_status_update.cjs +0 -458
- package/dist/active-citizen/workers/delayed_jobs.cjs +0 -244
- package/dist/active-citizen/workers/deletions.cjs +0 -1911
- package/dist/active-citizen/workers/email.cjs +0 -9
- package/dist/active-citizen/workers/fraud_management.cjs +0 -109
- package/dist/active-citizen/workers/generativeAi.js +0 -56
- package/dist/active-citizen/workers/main.cjs +0 -89
- package/dist/active-citizen/workers/marketing.cjs +0 -25
- package/dist/active-citizen/workers/moderation.cjs +0 -73
- package/dist/active-citizen/workers/notification_delivery.cjs +0 -368
- package/dist/active-citizen/workers/notification_news_feed.cjs +0 -142
- package/dist/active-citizen/workers/queue.cjs +0 -99
- package/dist/active-citizen/workers/recount.cjs +0 -74
- package/dist/active-citizen/workers/reports.cjs +0 -42
- package/dist/active-citizen/workers/similarities.cjs +0 -21
- package/dist/active-citizen/workers/speech_to_text.cjs +0 -482
- package/dist/agents/assistants/agentAssistant.js +0 -88
- package/dist/agents/assistants/baseAssistant.js +0 -888
- package/dist/agents/assistants/baseAssistantWithVoice.js +0 -150
- package/dist/agents/assistants/modes/agentDirectConnection.js +0 -84
- package/dist/agents/assistants/modes/agentSelectionMode.js +0 -44
- package/dist/agents/assistants/modes/baseAssistantMode.js +0 -54
- package/dist/agents/assistants/modes/tools/agentTools.js +0 -447
- package/dist/agents/assistants/modes/tools/baseTools.js +0 -58
- package/dist/agents/assistants/modes/tools/loginTools.js +0 -156
- package/dist/agents/assistants/modes/tools/models/agents.js +0 -146
- package/dist/agents/assistants/modes/tools/models/subscriptions.js +0 -332
- package/dist/agents/assistants/modes/tools/models/users.js +0 -11
- package/dist/agents/assistants/modes/tools/navigationTools.js +0 -166
- package/dist/agents/assistants/modes/tools/subscriptionTools.js +0 -323
- package/dist/agents/assistants/modes/tools/workflowConverstationTools.js +0 -112
- package/dist/agents/assistants/voiceAssistant.js +0 -619
- package/dist/agents/controllers/agentProductController.js +0 -103
- package/dist/agents/controllers/agentSubscriptionController.js +0 -261
- package/dist/agents/controllers/assistantsController.js +0 -511
- package/dist/agents/controllers/policySynthAgents.js +0 -395
- package/dist/agents/managers/agentProductManager.js +0 -91
- package/dist/agents/managers/emailInvitesManager.js +0 -55
- package/dist/agents/managers/emailTemplateRenderer.js +0 -362
- package/dist/agents/managers/newAiModelSetup.js +0 -650
- package/dist/agents/managers/notificationAgentQueueManager.js +0 -510
- package/dist/agents/managers/subscriptionManager.js +0 -535
- package/dist/agents/managers/workflowConversationManager.js +0 -79
- package/dist/agents/models/agentProduct.js +0 -116
- package/dist/agents/models/agentProductBoosterPurchase.js +0 -58
- package/dist/agents/models/agentProductBundle.js +0 -68
- package/dist/agents/models/agentProductRun.js +0 -52
- package/dist/agents/models/discount.js +0 -88
- package/dist/agents/models/subscription.js +0 -79
- package/dist/agents/models/subscriptionPlan.js +0 -46
- package/dist/agents/models/subscriptionUser.js +0 -27
- package/dist/agents/models/testData/createEvolyAgentProduct.js +0 -477
- package/dist/agents/models/testData/old/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/testData/setupEvolyAgentProductConfig.js +0 -233
- package/dist/agents/models/testData/updateAgentWorkflowConfiguration.js +0 -230
- package/dist/agents/models/workflowConversation.js +0 -53
- package/dist/agents/tools/setTemplateWorkflowCommunityId.js +0 -46
- package/dist/app.js +0 -943
- package/dist/authorization.cjs +0 -1860
- package/dist/bot_control.js +0 -1930
- package/dist/config/config.cjs +0 -14
- package/dist/config/config.js +0 -14
- package/dist/controllers/allOurIdeas.js +0 -696
- package/dist/controllers/audios.cjs +0 -100
- package/dist/controllers/bulkStatusUpdates.cjs +0 -202
- package/dist/controllers/categories.cjs +0 -199
- package/dist/controllers/communities.cjs +0 -2996
- package/dist/controllers/domains.cjs +0 -1341
- package/dist/controllers/externalIds.cjs +0 -223
- package/dist/controllers/groups.cjs +0 -4309
- package/dist/controllers/images.cjs +0 -499
- package/dist/controllers/index.cjs +0 -449
- package/dist/controllers/legacyPages.cjs +0 -35
- package/dist/controllers/legacyPosts.cjs +0 -56
- package/dist/controllers/legacyUsers.cjs +0 -36
- package/dist/controllers/nonSpa.cjs +0 -574
- package/dist/controllers/organizations.cjs +0 -250
- package/dist/controllers/points.cjs +0 -1137
- package/dist/controllers/posts.cjs +0 -2036
- package/dist/controllers/ratings.cjs +0 -234
- package/dist/controllers/users.cjs +0 -2255
- package/dist/controllers/videos.cjs +0 -226
- package/dist/deleteUnwantedDeclerations.cjs +0 -55
- package/dist/migrations/agentAuditLogs.cjs +0 -46
- package/dist/migrations/agentClasses.cjs +0 -60
- package/dist/migrations/agentConnectorClasses.cjs +0 -61
- package/dist/migrations/agentConnectors.cjs +0 -50
- package/dist/migrations/agentEvals.cjs +0 -45
- package/dist/migrations/agentRegistries.cjs +0 -40
- package/dist/migrations/agents.cjs +0 -54
- package/dist/migrations/aiModels.cjs +0 -49
- package/dist/migrations/apiUsage.cjs +0 -47
- package/dist/migrations/apis.cjs +0 -49
- package/dist/migrations/groupPrivateData.cjs +0 -30
- package/dist/migrations/modelUsage.cjs +0 -60
- package/dist/migrations/oldMigrations/2019/20181030020612-AddActivitiesIndex.js +0 -23
- package/dist/migrations/oldMigrations/2019/20181102210612-AddFirstVideoFeatures.js +0 -360
- package/dist/migrations/oldMigrations/2019/20181212210612-ModerationFeatures.js +0 -29
- package/dist/migrations/oldMigrations/2019/2019010610612-CommunityFolders.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190117020612-AddMissingIndexes.js +0 -24
- package/dist/migrations/oldMigrations/2019/20190117020612-RemoveUnusedIndexes.js +0 -29
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartThree.js +0 -22
- package/dist/migrations/oldMigrations/2019/20190127020612-RemoveUnusedIndexesPartTwo.js +0 -23
- package/dist/migrations/oldMigrations/2019/20190223020612-AddPrivateProfileDataToUsers.js +0 -18
- package/dist/migrations/oldMigrations/2019/20190706210612-AddCustomRatings.js +0 -43
- package/dist/migrations/oldMigrations/2019/20190829210612-AddGeneralStore.js +0 -36
- package/dist/migrations/oldMigrations/2019/20192811210612-AddAcClientActivities.js +0 -41
- package/dist/migrations/oldMigrations/2020/20190527020612-WorkOnIndexes.js +0 -88
- package/dist/migrations/oldMigrations/2020/20200409020612-AddBackgroundJob.js +0 -33
- package/dist/migrations/oldMigrations/2020/20200716210612-AddDataToCollections.js +0 -38
- package/dist/migrations/oldMigrations/2022/20220215100612-AddDataToEndorsements.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220220100612-AddDataForFraudDetection.js +0 -19
- package/dist/migrations/oldMigrations/2022/20220903100612-AddPromotionFeatures.js +0 -127
- package/dist/migrations/oldMigrations/2022/onHold/20200527020612-AddCampaigns.js +0 -68
- package/dist/migrations/oldMigrations/2024/20241304175112-AddMediaSupportForHtmlGroups.cjs +0 -63
- package/dist/migrations/oldMigrations/older/20160511172514-AddNotificationFeatures.js +0 -14
- package/dist/migrations/oldMigrations/older/20161030020612-AddBulkStatusUpdate.js +0 -71
- package/dist/migrations/oldMigrations/older/20170514035258-add-metadata-to-invites.js +0 -12
- package/dist/migrations/oldMigrations/older/20180216020612-AddTranslationCaches.js +0 -46
- package/dist/migrations/oldMigrations/older/20180218210612-AddTranslationAndLanguages.js +0 -46
- package/dist/migrations/privateAccessStore.cjs +0 -55
- package/dist/migrations/zzz_associations.cjs +0 -154
- package/dist/migrations/zzzz_createUsersAndAdminsForClasses.cjs +0 -100
- package/dist/migrations/zzzzz_create_agent_runs.cjs +0 -606
- package/dist/migrations/zzzzzz_create_agent_runs_fix.cjs +0 -11
- package/dist/migrations/zzzzzzz_create_trees.cjs +0 -81
- package/dist/models/audio.cjs +0 -430
- package/dist/models/bulk_status_update.cjs +0 -58
- package/dist/models/campaign.cjs +0 -78
- package/dist/models/category.cjs +0 -94
- package/dist/models/community.cjs +0 -337
- package/dist/models/domain.cjs +0 -486
- package/dist/models/endorsement.cjs +0 -39
- package/dist/models/general_data_store.cjs +0 -20
- package/dist/models/group.cjs +0 -728
- package/dist/models/image.cjs +0 -579
- package/dist/models/index.cjs +0 -186
- package/dist/models/invite.cjs +0 -48
- package/dist/models/iso_country.cjs +0 -16
- package/dist/models/organization.cjs +0 -122
- package/dist/models/page.cjs +0 -273
- package/dist/models/point.cjs +0 -622
- package/dist/models/point_quality.cjs +0 -39
- package/dist/models/point_revision.cjs +0 -47
- package/dist/models/post.cjs +0 -680
- package/dist/models/post_revision.cjs +0 -38
- package/dist/models/post_status_change.cjs +0 -35
- package/dist/models/promotion.cjs +0 -34
- package/dist/models/rating.cjs +0 -51
- package/dist/models/relationship.cjs +0 -19
- package/dist/models/request_to_join.cjs +0 -20
- package/dist/models/user.cjs +0 -604
- package/dist/models/user_legacy_password.cjs +0 -13
- package/dist/models/video.cjs +0 -1137
- package/dist/publish.js +0 -40
- package/dist/repack.js +0 -53
- package/dist/scripts/addRatingUsersToGroup.js +0 -51
- package/dist/scripts/addUserToOrganization.js +0 -71
- package/dist/scripts/analyseRatingsForCommunity.js +0 -150
- package/dist/scripts/analyzeAndFixBrokenPointUsers.js +0 -28
- package/dist/scripts/analyzeEndorsementsByCountry.js +0 -70
- package/dist/scripts/analyzePostsForCommunity.js +0 -185
- package/dist/scripts/bulkStatusUpdates/listUpdates.js +0 -14
- package/dist/scripts/bulkStatusUpdates/mergeLatestPostsToUpdate.js +0 -110
- package/dist/scripts/bulkStatusUpdates/performUpdate.js +0 -116
- package/dist/scripts/bulkStatusUpdates/performUpdateForGroup.cjs +0 -124
- package/dist/scripts/bulkStatusUpdates/performUpdateForStatus.js +0 -141
- package/dist/scripts/change/changeVideoAspectTo.js +0 -34
- package/dist/scripts/change/setUseNewVersion.cjs +0 -22
- package/dist/scripts/changeCommunityGroupcount.js +0 -30
- package/dist/scripts/changeCommunityPostCount.js +0 -30
- package/dist/scripts/changeGroupPostCount.js +0 -30
- package/dist/scripts/changeLanguage.js +0 -50
- package/dist/scripts/changeOfficalStatus.js +0 -30
- package/dist/scripts/cleanups/deleteAnonNotifications.cjs +0 -91
- package/dist/scripts/cleanups/deleteLinkGroupsWithDeletedCommunities.js +0 -62
- package/dist/scripts/cleanups/deleteYearOldNotifications.cjs +0 -72
- package/dist/scripts/cleanups/removeAllUsersFromHiddenPublicGroup.js +0 -43
- package/dist/scripts/clearAllEndorsementInGroup.js +0 -50
- package/dist/scripts/cloning/clearUsersForCommunitiesFromUrl.js +0 -129
- package/dist/scripts/cloning/cloneFromUrlScript.js +0 -65
- package/dist/scripts/cloning/cloneWBFromUrlScriptAndCreateLinks.js +0 -140
- package/dist/scripts/cloning/cloneWBFromUrlScriptNoUsersOrPoints.js +0 -140
- package/dist/scripts/cloning/cloneWBSerbianFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/copyCommunityConfigAndTranslationsFromURL.js +0 -173
- package/dist/scripts/cloning/copyCommunityOneGroupToDomainNoUsersNoEndorsements.js +0 -18
- package/dist/scripts/cloning/copyCommunityToDomainNoUsersNoEndorsements.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithEverything.js +0 -17
- package/dist/scripts/cloning/copyCommunityToDomainWithOnlyGroups.js +0 -26
- package/dist/scripts/cloning/copyGroupConfigAndTranslationsFromURL.js +0 -205
- package/dist/scripts/cloning/copyPostToGroupOld.js +0 -397
- package/dist/scripts/cloning/copyPostVideosFromURL.js +0 -236
- package/dist/scripts/cloning/copyPostWithOutAnyVotingOrActivities.js +0 -17
- package/dist/scripts/cloning/deepCloneSerbianWBFromUrlScriptAndCreateLinks.js +0 -131
- package/dist/scripts/cloning/deepCloneWBFromUrlScriptAndCreateLinks.js +0 -139
- package/dist/scripts/cloning/setAdminsFromURL.js +0 -161
- package/dist/scripts/cloning/setExternalIdsFromURL.js +0 -129
- package/dist/scripts/countCommunity.js +0 -291
- package/dist/scripts/countCommunityUsers.js +0 -152
- package/dist/scripts/countDelayedNotifications.js +0 -18
- package/dist/scripts/countGroup.js +0 -246
- package/dist/scripts/countStuff.js +0 -67
- package/dist/scripts/countUniqueVotersInAGroup.js +0 -48
- package/dist/scripts/createInvitesAndShow.js +0 -75
- package/dist/scripts/database/sync_database.js +0 -14
- package/dist/scripts/database/sync_dev_database.js +0 -17
- package/dist/scripts/debugNotifications.js +0 -58
- package/dist/scripts/deleteAllNewsFeeds.js +0 -10
- package/dist/scripts/deleteCategory.js +0 -13
- package/dist/scripts/deleteOldAppActivities.js +0 -40
- package/dist/scripts/deletePostContactDataForCommunity.js +0 -53
- package/dist/scripts/destroy/destroy_all_but_one_domain.js +0 -1026
- package/dist/scripts/displayAuthorForPost.js +0 -16
- package/dist/scripts/endorsementFraudDetection/analyseEndorsementsForCommunity.js +0 -183
- package/dist/scripts/endorsementFraudDetection/bulkDeleteDuplicateEndorsmentsFromUrl.js +0 -208
- package/dist/scripts/exportAllStatusChanges.js +0 -36
- package/dist/scripts/exportClientAcitivity.js +0 -36
- package/dist/scripts/exportEndorsementsForCommunity.js +0 -79
- package/dist/scripts/exportPointQualitiesForCommunity.js +0 -84
- package/dist/scripts/exportPostsAndPointsForCommunity.js +0 -147
- package/dist/scripts/exportPostsDataSetForDomain.js +0 -244
- package/dist/scripts/exportPostsForGroup.js +0 -173
- package/dist/scripts/exportRatingsForPost.js +0 -15
- package/dist/scripts/exportUserEndorsementsWithUserAnalysis.js +0 -123
- package/dist/scripts/exportUsersForCommunity.js +0 -24
- package/dist/scripts/exportUsersForDomain.js +0 -24
- package/dist/scripts/exportUsersForGroup.js +0 -24
- package/dist/scripts/exports/ratingDistribution.js +0 -71
- package/dist/scripts/exports/whoEndorsedWhatByCommunity.js +0 -56
- package/dist/scripts/findUnusedClientImports.js +0 -56
- package/dist/scripts/fixAllPostPointCounts.js +0 -22
- package/dist/scripts/fixAnonNotificationsSettings.js +0 -48
- package/dist/scripts/fixCountKopavogur.js +0 -9
- package/dist/scripts/fixEndorsementsAfterCopyPostToGroup.js +0 -190
- package/dist/scripts/fixExternalUserId.js +0 -24
- package/dist/scripts/fixGroupAccess.js +0 -16
- package/dist/scripts/fixGroupIdeasAndPointsCount.js +0 -49
- package/dist/scripts/fixNotificationSettings.js +0 -39
- package/dist/scripts/fixSurveyRadioBakedInSubCodes.js +0 -64
- package/dist/scripts/fixWrongUserIdForStatusUpdates.js +0 -49
- package/dist/scripts/gallery/exportGalleryData.js +0 -40
- package/dist/scripts/gallery/importGalleryForCommunity.js +0 -168
- package/dist/scripts/gallery/readJsonAndDownloadImagesVersion2.js +0 -55
- package/dist/scripts/gallery/refreshAcApiPostIdsForCommunity.js +0 -58
- package/dist/scripts/genderAnalysis.js +0 -63
- package/dist/scripts/genderAnalysisByStatus.js +0 -62
- package/dist/scripts/importAllLocalesFromLocalFolders.js +0 -55
- package/dist/scripts/importDomain.js +0 -1652
- package/dist/scripts/keys/addOidcToDomain.cjs +0 -61
- package/dist/scripts/landUseGame/export3Ddata.js +0 -162
- package/dist/scripts/listLanguagesForGroup.js +0 -54
- package/dist/scripts/loadTestCreateDummyContentForGroup.js +0 -27
- package/dist/scripts/makeRecursiveMapData.js +0 -103
- package/dist/scripts/mapping/community_map_csv.js +0 -145
- package/dist/scripts/moveCommunityToDomain.js +0 -22
- package/dist/scripts/moveGroupToCommunity.js +0 -23
- package/dist/scripts/movePostToGroup.js +0 -101
- package/dist/scripts/movePostsToGroupsRecountGroupFromUrl.js +0 -297
- package/dist/scripts/oldMovePostToGroup.js +0 -153
- package/dist/scripts/processCsvForPdfUrls.js +0 -37
- package/dist/scripts/processCsvForTranslationAndToxicity.js +0 -125
- package/dist/scripts/recount/recount_recursive_communities.js +0 -125
- package/dist/scripts/recountALLCommunityGroupCounts.js +0 -37
- package/dist/scripts/recountAll.js +0 -97
- package/dist/scripts/recountCommunitesFromUrl.js +0 -58
- package/dist/scripts/recountCommunity.js +0 -19
- package/dist/scripts/recountGroup.js +0 -218
- package/dist/scripts/recountGroupNoUserChange.js +0 -219
- package/dist/scripts/resetAllEndorsementsForGroup.js +0 -57
- package/dist/scripts/resetEnTranslationForGroup.js +0 -45
- package/dist/scripts/setAdminOnAll.cjs +0 -107
- package/dist/scripts/setDomainAdmin.cjs +0 -43
- package/dist/scripts/setDomainLocales.js +0 -33
- package/dist/scripts/setEarlQuestionIdOnGroup.cjs +0 -29
- package/dist/scripts/setLanguageOnGroupCommunitesFromUrl.js +0 -86
- package/dist/scripts/setMemberOfAll.js +0 -101
- package/dist/scripts/setNewUserForContentOfCommunity.js +0 -189
- package/dist/scripts/setOfficialStatusOnAllPostsForCommunity.js +0 -35
- package/dist/scripts/setUserOnAll.js +0 -101
- package/dist/scripts/showCategoryForGroup.js +0 -18
- package/dist/scripts/showOldActivityTypes.js +0 -14
- package/dist/scripts/showPostsMissingCategoryForGroup.js +0 -17
- package/dist/scripts/showStatuses.js +0 -17
- package/dist/scripts/showUniqueVotersInCommunity.js +0 -61
- package/dist/scripts/showUserAgentsAndIpsForEmails.js +0 -66
- package/dist/scripts/simpleExportForGroupsForCommunity.js +0 -46
- package/dist/scripts/simpleExportForPointsForCommunity.js +0 -82
- package/dist/scripts/simpleExportForPostsForCommunity.js +0 -61
- package/dist/scripts/testForEndorsments.js +0 -21
- package/dist/scripts/undeleteGroupAndAllContent.js +0 -151
- package/dist/scripts/undeletePost.js +0 -135
- package/dist/scripts/unlinkSsn.js +0 -23
- package/dist/scripts/updateFromAlthingi.js +0 -303
- package/dist/server.js +0 -3
- package/dist/utils/airbrake.cjs +0 -17
- package/dist/utils/cjsCodeReview.js +0 -99
- package/dist/utils/community_mapping_tools.cjs +0 -124
- package/dist/utils/copy_utils.cjs +0 -1399
- package/dist/utils/docx_utils.cjs +0 -464
- package/dist/utils/export_utils.cjs +0 -491
- package/dist/utils/i18n.cjs +0 -17
- package/dist/utils/is_valid_db_id.cjs +0 -28
- package/dist/utils/logger.cjs +0 -25
- package/dist/utils/loggerTs.js +0 -26
- package/dist/utils/manifest_generator.cjs +0 -104
- package/dist/utils/parse_domain.cjs +0 -16
- package/dist/utils/recount_utils.cjs +0 -415
- package/dist/utils/sharing_parameters.cjs +0 -111
- package/dist/utils/sitemap_generator.cjs +0 -286
- package/dist/utils/to_json.cjs +0 -14
- package/dist/utils/ypLanguages.js +0 -747
- package/dist/webSockets.js +0 -77
|
@@ -1,718 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const models = require("../../../models/index.cjs");
|
|
3
|
-
const async = require("async");
|
|
4
|
-
const moment = require("moment");
|
|
5
|
-
const log = require("../../utils/logger.cjs");
|
|
6
|
-
const _ = require("lodash");
|
|
7
|
-
const Excel = require("exceljs");
|
|
8
|
-
const getPointsUp = require("./common_utils.cjs").getPointsUp;
|
|
9
|
-
const getPointsDown = require("./common_utils.cjs").getPointsDown;
|
|
10
|
-
const getOrderedPosts = require("./common_utils.cjs").getOrderedPosts;
|
|
11
|
-
const updateJobStatusIfNeeded = require("./common_utils.cjs")
|
|
12
|
-
.updateJobStatusIfNeeded;
|
|
13
|
-
const setJobError = require("./common_utils.cjs").setJobError;
|
|
14
|
-
const preparePosts = require("./common_utils.cjs").preparePosts;
|
|
15
|
-
const uploadToS3 = require("./common_utils.cjs").uploadToS3;
|
|
16
|
-
const sanitizeFilename = require("sanitize-filename");
|
|
17
|
-
const { getAnswerFor } = require("./xls_community_users_report.cjs");
|
|
18
|
-
const { addPostPointsToSheet } = require("./add_points_to_sheet.cjs");
|
|
19
|
-
const getSubCodeFromDropdown = (dropdowns, answer) => {
|
|
20
|
-
if (dropdowns && answer.value) {
|
|
21
|
-
let subCode = answer.value.trim();
|
|
22
|
-
for (let i = 0; i < dropdowns.length; i++) {
|
|
23
|
-
if (dropdowns[i].text.trim() === answer.value.trim()) {
|
|
24
|
-
subCode = dropdowns[i].subCode;
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return subCode;
|
|
30
|
-
};
|
|
31
|
-
const getSubCodeFromRadio = (radios, answer) => {
|
|
32
|
-
if (radios && answer.value) {
|
|
33
|
-
let subCode = answer.value.trim();
|
|
34
|
-
for (let i = 0; i < radios.length; i++) {
|
|
35
|
-
if (radios[i].text.trim() === answer.value.trim()) {
|
|
36
|
-
subCode = radios[i].subCode;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return subCode;
|
|
42
|
-
};
|
|
43
|
-
const findCheckboxSubCode = (checkboxes, checkedAnswer) => {
|
|
44
|
-
let subCode = checkedAnswer;
|
|
45
|
-
if (checkboxes) {
|
|
46
|
-
for (let i = 0; i < checkboxes.length; i++) {
|
|
47
|
-
if (checkboxes[i].text.trim() === checkedAnswer.trim()) {
|
|
48
|
-
subCode = checkboxes[i].subCode;
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return subCode;
|
|
54
|
-
};
|
|
55
|
-
const getSubCodesFromCheckboxes = (question, answer) => {
|
|
56
|
-
let subCodes = [];
|
|
57
|
-
const checked = answer.split(",");
|
|
58
|
-
for (let i = 0; i < checked.length; i++) {
|
|
59
|
-
subCodes.push(findCheckboxSubCode(question.checkboxes, checked[i]));
|
|
60
|
-
}
|
|
61
|
-
return subCodes.join(",");
|
|
62
|
-
};
|
|
63
|
-
const getCheckboxDescription = (useSubCodes, answers, questionsById, i) => {
|
|
64
|
-
if (useSubCodes) {
|
|
65
|
-
return getSubCodesFromCheckboxes(questionsById[answers[i].uniqueId], answers[i].value);
|
|
66
|
-
}
|
|
67
|
-
else if (answers[i].value && answers[i].value.trim()) {
|
|
68
|
-
return answers[i].value.trim();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const getRadioDescription = (useSubCodes, answers, questionsById, i) => {
|
|
72
|
-
if (useSubCodes) {
|
|
73
|
-
return getSubCodeFromRadio(questionsById[answers[i].uniqueId].radioButtons, answers[i]);
|
|
74
|
-
}
|
|
75
|
-
else if (answers[i].value && answers[i].value.trim()) {
|
|
76
|
-
return answers[i].value.trim();
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const getDropdownDescription = (useSubCodes, answers, questionsById, i) => {
|
|
80
|
-
if (useSubCodes) {
|
|
81
|
-
return getSubCodeFromDropdown(questionsById[answers[i].uniqueId].dropdownOptions, answers[i]);
|
|
82
|
-
}
|
|
83
|
-
else if (answers[i].value && answers[i].value.trim()) {
|
|
84
|
-
return answers[i].value.trim();
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const getAnswerType = (answers, questionsById, i) => {
|
|
88
|
-
if (questionsById[answers[i].uniqueId]) {
|
|
89
|
-
return questionsById[answers[i].uniqueId].type;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
return "unknown";
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
const setDescriptionsNewStyle = (group, post, buildPost) => {
|
|
96
|
-
const questionsById = {};
|
|
97
|
-
const structuredAnswers = {};
|
|
98
|
-
let useSubCodes = false;
|
|
99
|
-
if (group.configuration && group.configuration.exportSubCodesForRadiosAndCheckboxes)
|
|
100
|
-
useSubCodes = true;
|
|
101
|
-
const questionComponents = group.configuration ? group.configuration.structuredQuestionsJson : [];
|
|
102
|
-
for (let i = 0; i < questionComponents.length; i++) {
|
|
103
|
-
questionsById[questionComponents[i].uniqueId] = questionComponents[i];
|
|
104
|
-
}
|
|
105
|
-
const answers = post.public_data.structuredAnswersJson;
|
|
106
|
-
for (let i = 0; i < answers.length; i += 1) {
|
|
107
|
-
if (answers[i] && answers[i].uniqueId) {
|
|
108
|
-
const answerType = getAnswerType(answers, questionsById, i);
|
|
109
|
-
if (answers[i].value && answerType === "radios") {
|
|
110
|
-
structuredAnswers[answers[i].uniqueId] = getRadioDescription(useSubCodes, answers, questionsById, i);
|
|
111
|
-
}
|
|
112
|
-
else if (answers[i].value && answerType === "checkboxes") {
|
|
113
|
-
structuredAnswers[answers[i].uniqueId] = getCheckboxDescription(useSubCodes, answers, questionsById, i);
|
|
114
|
-
}
|
|
115
|
-
else if (answers[i].value && answerType === "dropdown") {
|
|
116
|
-
structuredAnswers[answers[i].uniqueId] = getDropdownDescription(useSubCodes, answers, questionsById, i);
|
|
117
|
-
}
|
|
118
|
-
else if (answers[i].value && typeof answers[i].value === "string") {
|
|
119
|
-
structuredAnswers[answers[i].uniqueId] = answers[i].value.trim();
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
structuredAnswers[answers[i].uniqueId] = null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return structuredAnswers;
|
|
127
|
-
};
|
|
128
|
-
const setDescriptionsOldStyle = (group, post, buildPost) => {
|
|
129
|
-
const structuredAnswers = {};
|
|
130
|
-
const questionKeys = [];
|
|
131
|
-
var questionComponents = group.configuration.structuredQuestions.split(",");
|
|
132
|
-
for (var i = 0; i < questionComponents.length; i += 2) {
|
|
133
|
-
const question = questionComponents[i];
|
|
134
|
-
questionKeys.push(question.replace(/ /g, ""));
|
|
135
|
-
}
|
|
136
|
-
var answers = post.public_data.structuredAnswers.split("%!#x");
|
|
137
|
-
for (i = 0; i < answers.length; i += 1) {
|
|
138
|
-
if (answers[i]) {
|
|
139
|
-
const answerObject = {};
|
|
140
|
-
answerObject[`${questionKeys[i]}`] = answers[i].trim();
|
|
141
|
-
_.merge(structuredAnswers, answerObject);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return structuredAnswers;
|
|
145
|
-
};
|
|
146
|
-
const setDescriptions = (group, post, builtPost) => {
|
|
147
|
-
if (group &&
|
|
148
|
-
group.configuration &&
|
|
149
|
-
group.configuration.structuredQuestionsJson &&
|
|
150
|
-
post.public_data.structuredAnswersJson) {
|
|
151
|
-
return setDescriptionsNewStyle(group, post, builtPost);
|
|
152
|
-
}
|
|
153
|
-
else if (group &&
|
|
154
|
-
group.configuration &&
|
|
155
|
-
group.configuration.structuredQuestions &&
|
|
156
|
-
group.configuration.structuredQuestions !== "" &&
|
|
157
|
-
typeof group.configuration.structuredQuestions === "string" &&
|
|
158
|
-
post.public_data.structuredAnswers &&
|
|
159
|
-
post.public_data.structuredAnswers !== "") {
|
|
160
|
-
return setDescriptionsOldStyle(group, post, builtPost);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
return {
|
|
164
|
-
description: builtPost.translatedDescription
|
|
165
|
-
? builtPost.translatedDescription
|
|
166
|
-
: post.description,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
const getPointTextWithEverything = (group, post, point) => {
|
|
171
|
-
let pointContent;
|
|
172
|
-
let outText = "";
|
|
173
|
-
if (post.translatedPoints && post.translatedPoints[point.id]) {
|
|
174
|
-
pointContent = post.translatedPoints[point.id];
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
pointContent =
|
|
178
|
-
point.PointRevisions[point.PointRevisions.length - 1].content;
|
|
179
|
-
}
|
|
180
|
-
outText +=
|
|
181
|
-
moment(point.created_at).format("DD/MM/YY HH:mm") +
|
|
182
|
-
" - " +
|
|
183
|
-
point.User.name +
|
|
184
|
-
" - " +
|
|
185
|
-
point.User.email +
|
|
186
|
-
"\n\n";
|
|
187
|
-
outText += pointContent + "\n\n";
|
|
188
|
-
if (point.public_data &&
|
|
189
|
-
point.public_data.admin_comment &&
|
|
190
|
-
point.public_data.admin_comment.text) {
|
|
191
|
-
outText +=
|
|
192
|
-
(group.translatedCustomAdminCommentsTitle ||
|
|
193
|
-
group.configuration.customAdminCommentsTitle ||
|
|
194
|
-
"Admin comment") + "\n";
|
|
195
|
-
if (point.public_data.admin_comment.createdAt) {
|
|
196
|
-
outText +=
|
|
197
|
-
moment(point.created_at).format("DD/MM/YY HH:mm") +
|
|
198
|
-
" - " +
|
|
199
|
-
point.public_data.admin_comment.userName +
|
|
200
|
-
"\n\n";
|
|
201
|
-
}
|
|
202
|
-
let text = (post.translatedPoints &&
|
|
203
|
-
post.translatedPoints[point.id + "adminComments"]) ||
|
|
204
|
-
point.public_data.admin_comment.text ||
|
|
205
|
-
"";
|
|
206
|
-
outText += text + "\n\n";
|
|
207
|
-
}
|
|
208
|
-
return outText;
|
|
209
|
-
};
|
|
210
|
-
const getContactDataRow = function (post) {
|
|
211
|
-
if (post.data &&
|
|
212
|
-
post.data.contact &&
|
|
213
|
-
(post.data.contact.name ||
|
|
214
|
-
post.data.contact.email ||
|
|
215
|
-
post.data.contact.address ||
|
|
216
|
-
post.data.contact.telephone)) {
|
|
217
|
-
return {
|
|
218
|
-
contactName: post.data.contact.name,
|
|
219
|
-
contactEmail: post.data.contact.email,
|
|
220
|
-
contactTelephone: post.data.contact.telephone,
|
|
221
|
-
contactAddress: post.data.contact.address,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
return {};
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
const getAttachmentDataRow = function (post) {
|
|
229
|
-
if (post.data && post.data.attachment && post.data.attachment.url) {
|
|
230
|
-
return {
|
|
231
|
-
attachmentUrl: post.data.attachment.url,
|
|
232
|
-
attachmentFilename: post.data.attachment.filename,
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
return {};
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
const getPostRatingsRow = (customRatings, postRatings) => {
|
|
240
|
-
let out = {};
|
|
241
|
-
if (customRatings && customRatings.length > 0) {
|
|
242
|
-
customRatings.forEach((rating, index) => {
|
|
243
|
-
const oneOut = {};
|
|
244
|
-
if (postRatings && postRatings[index]) {
|
|
245
|
-
oneOut[rating.name + "count"] = postRatings[index].count;
|
|
246
|
-
oneOut[rating.name + "average"] = postRatings[index].averageRating;
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
oneOut[rating.name + "count"] = 0;
|
|
250
|
-
oneOut[rating.name + "average"] = 0;
|
|
251
|
-
}
|
|
252
|
-
_.merge(out, oneOut);
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
return out;
|
|
256
|
-
};
|
|
257
|
-
const addPostToSheet = (worksheet, post, group) => {
|
|
258
|
-
const mediaUrls = post.mediaURLs.replace(/"/g, "");
|
|
259
|
-
const row = {
|
|
260
|
-
postName: post.translatedName ? post.translatedName : post.name,
|
|
261
|
-
postId: post.realPost.id,
|
|
262
|
-
status: post.status,
|
|
263
|
-
createdAt: moment(post.realPost.created_at).format("DD/MM/YY HH:mm"),
|
|
264
|
-
email: post.userEmail,
|
|
265
|
-
userName: post.userName,
|
|
266
|
-
url: post.url,
|
|
267
|
-
postLocale: post.realPost.language,
|
|
268
|
-
images: post.images,
|
|
269
|
-
upVotes: post.endorsementsUp,
|
|
270
|
-
downVotes: post.endorsementsDown,
|
|
271
|
-
pointsCount: post.counterPoints,
|
|
272
|
-
mediaUrls: mediaUrls ? mediaUrls : " ",
|
|
273
|
-
category: post.category ? post.category : " ",
|
|
274
|
-
postTranscript: post.mediaTranscripts,
|
|
275
|
-
};
|
|
276
|
-
_.merge(row, setDescriptions(group, post.realPost, post));
|
|
277
|
-
if (group.configuration.moreContactInformation) {
|
|
278
|
-
_.merge(row, getContactDataRow(post.realPost));
|
|
279
|
-
}
|
|
280
|
-
if (group.configuration.attachmentsEnabled) {
|
|
281
|
-
_.merge(row, getAttachmentDataRow(post.realPost));
|
|
282
|
-
}
|
|
283
|
-
if (group.configuration.customRatings &&
|
|
284
|
-
post.realPost.public_data &&
|
|
285
|
-
post.realPost.public_data.ratings) {
|
|
286
|
-
_.merge(row, getPostRatingsRow(group.configuration.customRatings, post.realPost.public_data.ratings));
|
|
287
|
-
}
|
|
288
|
-
if (!group.configuration.locationHidden && post.realPost.location) {
|
|
289
|
-
_.merge(row, {
|
|
290
|
-
latitude: post.realPost.location.latitude,
|
|
291
|
-
longitude: post.realPost.location.longitude,
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
let pointsUpText = "";
|
|
295
|
-
const pointsUp = getPointsUp(post);
|
|
296
|
-
pointsUp.forEach((point) => {
|
|
297
|
-
pointsUpText += getPointTextWithEverything(group, post, point);
|
|
298
|
-
});
|
|
299
|
-
let pointsDownText = "";
|
|
300
|
-
const pointsDown = getPointsDown(post);
|
|
301
|
-
pointsDown.forEach((point) => {
|
|
302
|
-
pointsDownText += getPointTextWithEverything(group, post, point);
|
|
303
|
-
});
|
|
304
|
-
_.merge(row, {
|
|
305
|
-
pointsFor: pointsUpText,
|
|
306
|
-
pointsAgainst: pointsDownText,
|
|
307
|
-
});
|
|
308
|
-
const registrationQuestions = group.configuration.registrationQuestionsJson;
|
|
309
|
-
if (registrationQuestions && post.User && post.User.private_profile_data && post.User.private_profile_data.registration_answers) {
|
|
310
|
-
const answers = post.User.private_profile_data.registration_answers;
|
|
311
|
-
for (let i = 0; i < registrationQuestions.length; i++) {
|
|
312
|
-
if (registrationQuestions[i].type !== "segment" && registrationQuestions[i].type !== "textDescription") {
|
|
313
|
-
const key = registrationQuestions[i].text;
|
|
314
|
-
const value = getAnswerFor(registrationQuestions[i].text, answers);
|
|
315
|
-
_.merge(row, { [key]: value });
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
worksheet.addRow(row);
|
|
320
|
-
};
|
|
321
|
-
const getDescriptionHeadersNewStyle = (group) => {
|
|
322
|
-
var questionComponents = group.configuration.structuredQuestionsJson;
|
|
323
|
-
let columnsStrings = [];
|
|
324
|
-
for (var i = 0; i < questionComponents.length; i++) {
|
|
325
|
-
var question = questionComponents[i];
|
|
326
|
-
if (question.uniqueId) {
|
|
327
|
-
columnsStrings.push({
|
|
328
|
-
header: question.uniqueId + "-" + question.text,
|
|
329
|
-
key: question.uniqueId,
|
|
330
|
-
width: 45,
|
|
331
|
-
style: { numFmt: "@" },
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return columnsStrings;
|
|
336
|
-
};
|
|
337
|
-
const getDescriptionHeadersOldStyle = (group) => {
|
|
338
|
-
var structuredQuestions = [];
|
|
339
|
-
var questionComponents = group.configuration.structuredQuestions.split(",");
|
|
340
|
-
for (var i = 0; i < questionComponents.length; i += 2) {
|
|
341
|
-
var question = questionComponents[i];
|
|
342
|
-
var maxLength = questionComponents[i + 1];
|
|
343
|
-
structuredQuestions.push({
|
|
344
|
-
translatedContent: question,
|
|
345
|
-
question: question,
|
|
346
|
-
maxLength: maxLength,
|
|
347
|
-
value: "",
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
let columnsStrings = [];
|
|
351
|
-
structuredQuestions.forEach((question) => {
|
|
352
|
-
columnsStrings.push({
|
|
353
|
-
header: question.translatedContent,
|
|
354
|
-
key: question.translatedContent.replace(/ /g, ""),
|
|
355
|
-
width: 45,
|
|
356
|
-
style: { numFmt: "@" },
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
return columnsStrings;
|
|
360
|
-
};
|
|
361
|
-
const getDescriptionHeaders = (group) => {
|
|
362
|
-
if (group && group.configuration.structuredQuestionsJson) {
|
|
363
|
-
return getDescriptionHeadersNewStyle(group);
|
|
364
|
-
}
|
|
365
|
-
else if (group &&
|
|
366
|
-
group.configuration.structuredQuestions &&
|
|
367
|
-
group.configuration.structuredQuestions !== "") {
|
|
368
|
-
return getDescriptionHeadersOldStyle(group);
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
return {
|
|
372
|
-
header: "Description",
|
|
373
|
-
key: "description",
|
|
374
|
-
width: 45,
|
|
375
|
-
style: { numFmt: "@" },
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
const getRatingHeaders = (customRatings) => {
|
|
380
|
-
let out = [];
|
|
381
|
-
if (customRatings && customRatings.length > 0) {
|
|
382
|
-
customRatings.forEach((rating) => {
|
|
383
|
-
out.push({
|
|
384
|
-
header: rating.name + " count",
|
|
385
|
-
key: rating.name + "count",
|
|
386
|
-
width: 20,
|
|
387
|
-
});
|
|
388
|
-
out.push({
|
|
389
|
-
header: rating.name + " average",
|
|
390
|
-
key: rating.name + "average",
|
|
391
|
-
width: 10,
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
return out;
|
|
396
|
-
};
|
|
397
|
-
const setWrapping = (worksheet) => {
|
|
398
|
-
for (let rowIndex = 0; rowIndex <= worksheet.rowCount; rowIndex++) {
|
|
399
|
-
const row = worksheet.getRow(rowIndex);
|
|
400
|
-
row.eachCell({ includeEmpty: true }, (cell) => {
|
|
401
|
-
if (cell._column._key === "pointsFor" ||
|
|
402
|
-
cell._column._key === "pointsAgainst") {
|
|
403
|
-
cell.alignment = { vertical: "top", wrapText: true };
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
worksheet.getRow(1).font = { bold: true };
|
|
408
|
-
// worksheet.properties.defaultRowHeight = 20;
|
|
409
|
-
};
|
|
410
|
-
async function exportToXls(options, callback) {
|
|
411
|
-
const jobId = options.jobId;
|
|
412
|
-
const groupId = options.groupId;
|
|
413
|
-
const group = options.group;
|
|
414
|
-
const posts = options.posts;
|
|
415
|
-
let categories = options.categories;
|
|
416
|
-
const customRatings = options.customRatings;
|
|
417
|
-
const title = "Export for Group Id: " + group.id;
|
|
418
|
-
const ratingsHeaders = getRatingHeaders(customRatings);
|
|
419
|
-
const workbook = new Excel.Workbook();
|
|
420
|
-
workbook.creator = "Your Priorities - Automated";
|
|
421
|
-
workbook.created = new Date();
|
|
422
|
-
let name = group.translatedName ? group.translatedName : group.name;
|
|
423
|
-
name = name.replace(/\*/g, '');
|
|
424
|
-
name = name.replace(/\?/g, '');
|
|
425
|
-
name = name.replace(/:/g, '');
|
|
426
|
-
name = name.replace(/\//g, '');
|
|
427
|
-
name = name.replace(/\\/g, '');
|
|
428
|
-
name = name.replace(/\[/g, '');
|
|
429
|
-
name = name.replace(/\]/g, '');
|
|
430
|
-
const worksheet = workbook.addWorksheet(`Posts - ${name}`);
|
|
431
|
-
const worksheetPoints = workbook.addWorksheet(`Points - ${name}`);
|
|
432
|
-
worksheetPoints.columns = [
|
|
433
|
-
{ header: "Group Id", key: "groupId", width: 15 },
|
|
434
|
-
{ header: "Post Id", key: "postId", width: 15 },
|
|
435
|
-
{ header: "Post Name", key: "postName", width: 30 },
|
|
436
|
-
{ header: "Status", key: "status", width: 15 },
|
|
437
|
-
{ header: "Created", key: "createdAt", width: 15 },
|
|
438
|
-
{ header: "User name", key: "userName", width: 30 },
|
|
439
|
-
{ header: "Email", key: "email", width: 30 },
|
|
440
|
-
{ header: "Value", key: "value", width: 15 },
|
|
441
|
-
{ header: "Helpful Count", key: "helpfulCount", width: 15 },
|
|
442
|
-
{ header: "Unhelpful Count", key: "unhelpfulCount", width: 15 },
|
|
443
|
-
{ header: "Language", key: "pointLocale", width: 15 },
|
|
444
|
-
{ header: "Content", key: "pointContentLatest", width: 150 },
|
|
445
|
-
{ header: "Media URLs", key: "mediaUrls", width: 15 },
|
|
446
|
-
{ header: "Point transcripts", key: "pointTranscript", width: 50 }
|
|
447
|
-
];
|
|
448
|
-
let columns = [
|
|
449
|
-
{ header: "Created", key: "createdAt", width: 15 },
|
|
450
|
-
{ header: "Status", key: "status", width: 15 },
|
|
451
|
-
{ header: "Post Id", key: "postId", width: 15 },
|
|
452
|
-
{ header: "User name", key: "userName", width: 30 },
|
|
453
|
-
{ header: "Email", key: "email", width: 30 },
|
|
454
|
-
];
|
|
455
|
-
if (group.configuration.moreContactInformation) {
|
|
456
|
-
columns.push({ header: "Contact Name", key: "contactName", width: 30 }, { header: "Contact Email", key: "contactEmail", width: 30 }, { header: "Contact telephone", key: "contactTelephone", width: 20 });
|
|
457
|
-
}
|
|
458
|
-
if (group.configuration.moreContactInformationAddress) {
|
|
459
|
-
columns.push({
|
|
460
|
-
header: "Contact Address",
|
|
461
|
-
key: "contactAddress",
|
|
462
|
-
width: 50,
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
if (group.configuration.attachmentsEnabled) {
|
|
466
|
-
columns.push({ header: "Attachment URL", key: "attachmentUrl", width: 30 }, { header: "Attachment filename", key: "attachmentFilename", width: 30 });
|
|
467
|
-
}
|
|
468
|
-
columns.push({
|
|
469
|
-
header: "Post name",
|
|
470
|
-
key: "postName",
|
|
471
|
-
width: 45,
|
|
472
|
-
style: { numFmt: "@" },
|
|
473
|
-
});
|
|
474
|
-
columns = columns.concat(getDescriptionHeaders(group));
|
|
475
|
-
columns.push({ header: "Locale", key: "postLocale", width: 10 });
|
|
476
|
-
if (!group.configuration.locationHidden) {
|
|
477
|
-
columns.push({ header: "Latitude", key: "latitude", width: 15 }, { header: "Longitude", key: "longitude", width: 15 });
|
|
478
|
-
}
|
|
479
|
-
columns.push({ header: "URL", key: "url", width: 20 }, { header: "Category", key: "category", width: 15 }, { header: "Up Votes", key: "upVotes", width: 15 }, { header: "Down Votes", key: "downVotes", width: 15 });
|
|
480
|
-
if (ratingsHeaders.length > 0) {
|
|
481
|
-
columns = columns.concat(ratingsHeaders);
|
|
482
|
-
}
|
|
483
|
-
let pointForHeader = group.translatedAlternativePointForHeader ||
|
|
484
|
-
group.configuration.alternativePointForHeader ||
|
|
485
|
-
"Points For";
|
|
486
|
-
let pointAgainstHeader = group.translatedAlternativePointAgainstHeader ||
|
|
487
|
-
group.configuration.alternativePointAgainstHeader ||
|
|
488
|
-
"Points Against";
|
|
489
|
-
columns.push({ header: "Points Count", key: "pointsCount", width: 15 }, {
|
|
490
|
-
header: pointForHeader,
|
|
491
|
-
key: "pointsFor",
|
|
492
|
-
width: 55,
|
|
493
|
-
style: { numFmt: "@" },
|
|
494
|
-
}, {
|
|
495
|
-
header: pointAgainstHeader,
|
|
496
|
-
key: "pointsAgainst",
|
|
497
|
-
width: 55,
|
|
498
|
-
style: { numFmt: "@" },
|
|
499
|
-
}, { header: "Images", key: "images", width: 20 }, { header: "Media URLs", key: "mediaUrls", width: 15 }, { header: "Post transcript", key: "postTranscript", width: 15 });
|
|
500
|
-
const registrationQuestions = group.configuration.registrationQuestionsJson;
|
|
501
|
-
if (registrationQuestions) {
|
|
502
|
-
for (let i = 0; i < registrationQuestions.length; i++) {
|
|
503
|
-
if (registrationQuestions[i].type !== "segment" && registrationQuestions[i].type !== "textDescription") {
|
|
504
|
-
try {
|
|
505
|
-
columns.push({
|
|
506
|
-
header: registrationQuestions[i].text,
|
|
507
|
-
key: registrationQuestions[i].text,
|
|
508
|
-
width: 30
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
catch (ex) {
|
|
512
|
-
log.error(ex);
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
worksheet.columns = columns;
|
|
518
|
-
let processedCount = 0;
|
|
519
|
-
let lastReportedCount = 0;
|
|
520
|
-
const totalPostCount = posts.length;
|
|
521
|
-
if (categories.length === 0) {
|
|
522
|
-
async.eachSeries(getOrderedPosts(posts), (post, eachCallback) => {
|
|
523
|
-
addPostToSheet(worksheet, post, group);
|
|
524
|
-
addPostPointsToSheet(worksheetPoints, post, group);
|
|
525
|
-
processedCount += 1;
|
|
526
|
-
updateJobStatusIfNeeded(jobId, totalPostCount, processedCount, lastReportedCount, (error, haveSent) => {
|
|
527
|
-
if (haveSent)
|
|
528
|
-
lastReportedCount = processedCount;
|
|
529
|
-
eachCallback(error);
|
|
530
|
-
});
|
|
531
|
-
}, async (error) => {
|
|
532
|
-
if (error) {
|
|
533
|
-
callback(error);
|
|
534
|
-
}
|
|
535
|
-
else {
|
|
536
|
-
setWrapping(worksheet);
|
|
537
|
-
const buffer = await workbook.xlsx.writeBuffer();
|
|
538
|
-
callback(null, buffer);
|
|
539
|
-
}
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
else {
|
|
543
|
-
async.series([
|
|
544
|
-
(seriesCallback) => {
|
|
545
|
-
categories = _.orderBy(categories, [(category) => category]);
|
|
546
|
-
async.eachSeries(categories, (category, categoryCallback) => {
|
|
547
|
-
async.eachSeries(getOrderedPosts(posts), (post, eachCallback) => {
|
|
548
|
-
if (post.category === category) {
|
|
549
|
-
addPostToSheet(worksheet, post, group);
|
|
550
|
-
addPostPointsToSheet(worksheetPoints, post, group);
|
|
551
|
-
processedCount += 1;
|
|
552
|
-
updateJobStatusIfNeeded(jobId, totalPostCount, processedCount, lastReportedCount, (error, haveSent) => {
|
|
553
|
-
if (haveSent) {
|
|
554
|
-
lastReportedCount = processedCount;
|
|
555
|
-
}
|
|
556
|
-
eachCallback(error);
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
else {
|
|
560
|
-
eachCallback();
|
|
561
|
-
}
|
|
562
|
-
}, (error) => {
|
|
563
|
-
categoryCallback(error);
|
|
564
|
-
});
|
|
565
|
-
}, (error) => {
|
|
566
|
-
seriesCallback(error);
|
|
567
|
-
});
|
|
568
|
-
},
|
|
569
|
-
(seriesCallback) => {
|
|
570
|
-
const postsWithoutCategories = [];
|
|
571
|
-
posts.forEach((post) => {
|
|
572
|
-
if (!post.category) {
|
|
573
|
-
postsWithoutCategories.push(post);
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
if (postsWithoutCategories.length > 0) {
|
|
577
|
-
async.eachSeries(getOrderedPosts(postsWithoutCategories), (post, eachCallback) => {
|
|
578
|
-
addPostToSheet(worksheet, post, group);
|
|
579
|
-
addPostPointsToSheet(worksheetPoints, post, group);
|
|
580
|
-
processedCount += 1;
|
|
581
|
-
updateJobStatusIfNeeded(jobId, totalPostCount, processedCount, lastReportedCount, (error, haveSent) => {
|
|
582
|
-
if (haveSent) {
|
|
583
|
-
lastReportedCount = processedCount;
|
|
584
|
-
}
|
|
585
|
-
eachCallback(error);
|
|
586
|
-
});
|
|
587
|
-
}, (error) => {
|
|
588
|
-
seriesCallback(error);
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
else {
|
|
592
|
-
seriesCallback();
|
|
593
|
-
}
|
|
594
|
-
},
|
|
595
|
-
], async (error) => {
|
|
596
|
-
if (error) {
|
|
597
|
-
callback(error);
|
|
598
|
-
}
|
|
599
|
-
else {
|
|
600
|
-
setWrapping(worksheet);
|
|
601
|
-
const buffer = await workbook.xlsx.writeBuffer();
|
|
602
|
-
callback(null, buffer);
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
const createXlsReport = (workPackage, callback) => {
|
|
608
|
-
let exportOptions, exportedData, filename;
|
|
609
|
-
async.series([
|
|
610
|
-
(seriesCallback) => {
|
|
611
|
-
models.Group.findOne({
|
|
612
|
-
where: {
|
|
613
|
-
id: workPackage.groupId,
|
|
614
|
-
},
|
|
615
|
-
attributes: [
|
|
616
|
-
"id",
|
|
617
|
-
"name",
|
|
618
|
-
"objectives",
|
|
619
|
-
"configuration",
|
|
620
|
-
"community_id",
|
|
621
|
-
],
|
|
622
|
-
include: [
|
|
623
|
-
{
|
|
624
|
-
model: models.Image,
|
|
625
|
-
as: "GroupLogoImages",
|
|
626
|
-
attributes: models.Image.defaultAttributesPublic,
|
|
627
|
-
required: false,
|
|
628
|
-
},
|
|
629
|
-
],
|
|
630
|
-
order: [
|
|
631
|
-
[
|
|
632
|
-
{ model: models.Image, as: "GroupLogoImages" },
|
|
633
|
-
"created_at",
|
|
634
|
-
"desc",
|
|
635
|
-
],
|
|
636
|
-
],
|
|
637
|
-
})
|
|
638
|
-
.then((group) => {
|
|
639
|
-
workPackage.group = group;
|
|
640
|
-
const dateString = moment(new Date()).format("DD_MM_YY_HH_mm");
|
|
641
|
-
const groupName = sanitizeFilename(group.name).replace(/ /g, "");
|
|
642
|
-
workPackage.filename =
|
|
643
|
-
"Ideas_and_Points_Group_Export_" +
|
|
644
|
-
group.community_id +
|
|
645
|
-
"_" +
|
|
646
|
-
group.id +
|
|
647
|
-
"_" +
|
|
648
|
-
groupName +
|
|
649
|
-
"_" +
|
|
650
|
-
dateString +
|
|
651
|
-
"." +
|
|
652
|
-
workPackage.exportType;
|
|
653
|
-
seriesCallback();
|
|
654
|
-
})
|
|
655
|
-
.catch((error) => {
|
|
656
|
-
seriesCallback(error);
|
|
657
|
-
});
|
|
658
|
-
},
|
|
659
|
-
(seriesCallback) => {
|
|
660
|
-
preparePosts(workPackage, (error, options) => {
|
|
661
|
-
exportOptions = options;
|
|
662
|
-
seriesCallback(error);
|
|
663
|
-
});
|
|
664
|
-
},
|
|
665
|
-
(seriesCallback) => {
|
|
666
|
-
models.AcBackgroundJob.update({
|
|
667
|
-
progress: 5,
|
|
668
|
-
}, {
|
|
669
|
-
where: { id: workPackage.jobId },
|
|
670
|
-
})
|
|
671
|
-
.then(() => {
|
|
672
|
-
seriesCallback();
|
|
673
|
-
})
|
|
674
|
-
.catch((error) => {
|
|
675
|
-
seriesCallback(error);
|
|
676
|
-
});
|
|
677
|
-
},
|
|
678
|
-
(seriesCallback) => {
|
|
679
|
-
exportToXls(exportOptions, (error, data) => {
|
|
680
|
-
exportedData = data;
|
|
681
|
-
seriesCallback(error);
|
|
682
|
-
});
|
|
683
|
-
},
|
|
684
|
-
(seriesCallback) => {
|
|
685
|
-
uploadToS3(workPackage.jobId, workPackage.userId, workPackage.filename, workPackage.exportType, exportedData, (error, reportUrl) => {
|
|
686
|
-
if (error) {
|
|
687
|
-
seriesCallback(error);
|
|
688
|
-
}
|
|
689
|
-
else {
|
|
690
|
-
models.AcBackgroundJob.update({
|
|
691
|
-
progress: 100,
|
|
692
|
-
data: { reportUrl },
|
|
693
|
-
}, {
|
|
694
|
-
where: { id: workPackage.jobId },
|
|
695
|
-
})
|
|
696
|
-
.then(() => {
|
|
697
|
-
seriesCallback();
|
|
698
|
-
})
|
|
699
|
-
.catch((error) => {
|
|
700
|
-
seriesCallback(error);
|
|
701
|
-
});
|
|
702
|
-
}
|
|
703
|
-
});
|
|
704
|
-
},
|
|
705
|
-
], (error) => {
|
|
706
|
-
if (error) {
|
|
707
|
-
setJobError(workPackage.jobId, "errorXlsReportGeneration", error, (dbError) => {
|
|
708
|
-
callback(dbError || error);
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
else {
|
|
712
|
-
callback();
|
|
713
|
-
}
|
|
714
|
-
});
|
|
715
|
-
};
|
|
716
|
-
module.exports = {
|
|
717
|
-
createXlsReport,
|
|
718
|
-
};
|