@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,232 +0,0 @@
|
|
|
1
|
-
import ExcelJS from "exceljs";
|
|
2
|
-
import fetch from "node-fetch";
|
|
3
|
-
import { Headers } from "node-fetch";
|
|
4
|
-
import { v4 as uuidv4 } from "uuid";
|
|
5
|
-
import models from "../../../models/index.cjs";
|
|
6
|
-
import { setJobError, updateUploadJobStatus, uploadToS3, } from "./commonUtils.js";
|
|
7
|
-
const dbModels = models;
|
|
8
|
-
const Image = dbModels.Image;
|
|
9
|
-
const PAIRWISE_API_HOST = process.env.PAIRWISE_API_HOST; // Your API host
|
|
10
|
-
const defaultAuthHeader = new Headers({
|
|
11
|
-
"Content-Type": "application/json",
|
|
12
|
-
Authorization: `Basic ${Buffer.from(`${process.env.PAIRWISE_USERNAME}:${process.env.PAIRWISE_PASSWORD}`).toString("base64")}`,
|
|
13
|
-
});
|
|
14
|
-
async function fetchChoices(questionId, utmSource) {
|
|
15
|
-
try {
|
|
16
|
-
const url = `${PAIRWISE_API_HOST}/questions/${questionId}/choices.json?include_inactive=true&show_all=true${utmSource ? `?utm_source=${utmSource}` : ""}`;
|
|
17
|
-
const response = await fetch(url, {
|
|
18
|
-
method: "GET",
|
|
19
|
-
headers: defaultAuthHeader,
|
|
20
|
-
});
|
|
21
|
-
console.log(url);
|
|
22
|
-
if (!response.ok) {
|
|
23
|
-
console.error(response.statusText);
|
|
24
|
-
throw new Error("Fetching choices failed.");
|
|
25
|
-
}
|
|
26
|
-
const choices = (await response.json());
|
|
27
|
-
return choices;
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
console.error("Error fetching choices:", error);
|
|
31
|
-
throw error;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async function fetchVotes(questionId, choiceId, utmSource) {
|
|
35
|
-
try {
|
|
36
|
-
let url = `${PAIRWISE_API_HOST}/questions/${questionId}/choices/${choiceId}/show_votes.json`;
|
|
37
|
-
if (utmSource) {
|
|
38
|
-
url += `&utm_source=${utmSource}`;
|
|
39
|
-
}
|
|
40
|
-
const response = await fetch(url, {
|
|
41
|
-
method: "GET",
|
|
42
|
-
headers: defaultAuthHeader,
|
|
43
|
-
});
|
|
44
|
-
if (!response.ok) {
|
|
45
|
-
console.error(response.statusText);
|
|
46
|
-
throw new Error("Fetching votes failed.");
|
|
47
|
-
}
|
|
48
|
-
const votes = (await response.json());
|
|
49
|
-
return votes;
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
console.error("Error fetching votes:", error);
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function calculateElo(rating1, rating2, score1, score2) {
|
|
57
|
-
const kFactor = 32;
|
|
58
|
-
const expected1 = 1.0 / (1 + Math.pow(10, (rating2 - rating1) / 400.0));
|
|
59
|
-
const expected2 = 1.0 / (1 + Math.pow(10, (rating1 - rating2) / 400.0));
|
|
60
|
-
const newRating1 = rating1 + kFactor * (score1 - expected1);
|
|
61
|
-
const newRating2 = rating2 + kFactor * (score2 - expected2);
|
|
62
|
-
return [newRating1, newRating2];
|
|
63
|
-
}
|
|
64
|
-
export async function exportChoiceVotes(workPackage, done) {
|
|
65
|
-
try {
|
|
66
|
-
await updateUploadJobStatus(workPackage.jobId, 5);
|
|
67
|
-
console.log(`Exporting choice votes for question ${workPackage.questionId} with utm_source ${workPackage.utmSource}`);
|
|
68
|
-
const choices = (await fetchChoices(workPackage.questionId, workPackage.utmSource));
|
|
69
|
-
console.log(`Found ${choices.length} choices`);
|
|
70
|
-
const workbook = new ExcelJS.Workbook();
|
|
71
|
-
const choicesSheet = workbook.addWorksheet("Choices");
|
|
72
|
-
const winningVotesSheet = workbook.addWorksheet("Winning Votes");
|
|
73
|
-
const losingVotesSheet = workbook.addWorksheet("Losing Votes");
|
|
74
|
-
// Setting the headers
|
|
75
|
-
const choicesHeaders = [
|
|
76
|
-
"Id",
|
|
77
|
-
"Question Id",
|
|
78
|
-
"Wins",
|
|
79
|
-
"Losses",
|
|
80
|
-
"Votes",
|
|
81
|
-
"Score",
|
|
82
|
-
"Data",
|
|
83
|
-
"Elo Rating",
|
|
84
|
-
"Seed",
|
|
85
|
-
];
|
|
86
|
-
choicesSheet.addRow(choicesHeaders);
|
|
87
|
-
const votesHeaders = [
|
|
88
|
-
"Id",
|
|
89
|
-
"Voter Id",
|
|
90
|
-
"Question Id",
|
|
91
|
-
"Prompt Id",
|
|
92
|
-
"Choice Id",
|
|
93
|
-
"Loser Choice Id",
|
|
94
|
-
"Created At",
|
|
95
|
-
"Updated At",
|
|
96
|
-
"Time Viewed",
|
|
97
|
-
"UTM Source",
|
|
98
|
-
"UTM Campaign",
|
|
99
|
-
"UTM Medium",
|
|
100
|
-
"UTM Content",
|
|
101
|
-
];
|
|
102
|
-
winningVotesSheet.addRow(votesHeaders);
|
|
103
|
-
losingVotesSheet.addRow(votesHeaders);
|
|
104
|
-
const choiceVoteMap = new Map();
|
|
105
|
-
for (let i = 0; i < choices.length; i++) {
|
|
106
|
-
const choice = choices[i];
|
|
107
|
-
const votes = (await fetchVotes(workPackage.questionId, choice.id, workPackage.utmSource));
|
|
108
|
-
choiceVoteMap.set(choice.id, votes);
|
|
109
|
-
const voteCount = choice.wins + choice.losses;
|
|
110
|
-
let data = choice.data;
|
|
111
|
-
try {
|
|
112
|
-
const jsonData = JSON.parse(choice.data);
|
|
113
|
-
debugger;
|
|
114
|
-
if (jsonData && jsonData.content) {
|
|
115
|
-
data = jsonData.content;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
}
|
|
120
|
-
choicesSheet.addRow([
|
|
121
|
-
choice.id,
|
|
122
|
-
workPackage.questionId,
|
|
123
|
-
choice.wins,
|
|
124
|
-
choice.losses,
|
|
125
|
-
voteCount,
|
|
126
|
-
Math.round(choice.score),
|
|
127
|
-
data,
|
|
128
|
-
"N/A",
|
|
129
|
-
choice.user_created ? "User" : "Seed",
|
|
130
|
-
]);
|
|
131
|
-
votes.winning_votes.forEach((vote) => {
|
|
132
|
-
console.log(`${vote.tracking ? JSON.stringify(vote.tracking) : ""}`);
|
|
133
|
-
winningVotesSheet.addRow([
|
|
134
|
-
vote.id,
|
|
135
|
-
vote.voter_id,
|
|
136
|
-
vote.question_id,
|
|
137
|
-
vote.prompt_id,
|
|
138
|
-
vote.choice_id,
|
|
139
|
-
vote.loser_choice_id,
|
|
140
|
-
vote.created_at,
|
|
141
|
-
vote.updated_at,
|
|
142
|
-
vote.time_viewed,
|
|
143
|
-
vote.tracking?.utm_source,
|
|
144
|
-
vote.tracking?.utm_campaign,
|
|
145
|
-
vote.tracking?.utm_medium,
|
|
146
|
-
vote.tracking?.utm_content,
|
|
147
|
-
]);
|
|
148
|
-
});
|
|
149
|
-
votes.losing_votes.forEach((vote) => {
|
|
150
|
-
losingVotesSheet.addRow([
|
|
151
|
-
vote.id,
|
|
152
|
-
vote.voter_id,
|
|
153
|
-
vote.question_id,
|
|
154
|
-
vote.prompt_id,
|
|
155
|
-
vote.choice_id,
|
|
156
|
-
vote.loser_choice_id,
|
|
157
|
-
vote.created_at,
|
|
158
|
-
vote.updated_at,
|
|
159
|
-
vote.time_viewed,
|
|
160
|
-
vote.tracking?.utm_source,
|
|
161
|
-
vote.tracking?.utm_campaign,
|
|
162
|
-
vote.tracking?.utm_medium,
|
|
163
|
-
vote.tracking?.utm_content,
|
|
164
|
-
]);
|
|
165
|
-
});
|
|
166
|
-
const progress = Math.round((i / choices.length) * 95); // Scale to 95% maximum to leave room for final steps
|
|
167
|
-
await updateUploadJobStatus(workPackage.jobId, Math.max(progress, 99));
|
|
168
|
-
}
|
|
169
|
-
const eloRatings = new Map();
|
|
170
|
-
choices.forEach(choice => {
|
|
171
|
-
eloRatings.set(choice.id, 1000); // Default ELO rating
|
|
172
|
-
});
|
|
173
|
-
// NowvotesMap, iterate over choices to compute ELO ratings without fetching votes again
|
|
174
|
-
choices.forEach(choice1 => {
|
|
175
|
-
choices.forEach(choice2 => {
|
|
176
|
-
if (choice1.id === choice2.id)
|
|
177
|
-
return; // Skip comparison with itself
|
|
178
|
-
// Assuming votesMap is a Map where each entry's key is a choice ID
|
|
179
|
-
// and its value is an object with winning_votes and losing_votes arrays
|
|
180
|
-
const votes1 = choiceVoteMap.get(choice1.id);
|
|
181
|
-
const votes2 = choiceVoteMap.get(choice2.id);
|
|
182
|
-
const directVotes1 = votes1?.winning_votes.filter(vote => vote.loser_choice_id === choice2.id) || [];
|
|
183
|
-
const directVotes2 = votes2?.winning_votes.filter(vote => vote.loser_choice_id === choice1.id) || [];
|
|
184
|
-
if (directVotes1.length === 0 && directVotes2.length === 0)
|
|
185
|
-
return;
|
|
186
|
-
const score1 = directVotes1.length / (directVotes1.length + directVotes2.length);
|
|
187
|
-
const score2 = directVotes2.length / (directVotes2.length + directVotes1.length);
|
|
188
|
-
const currentRating1 = eloRatings.get(choice1.id) || 1500;
|
|
189
|
-
const currentRating2 = eloRatings.get(choice2.id) || 1500;
|
|
190
|
-
const [newRating1, newRating2] = calculateElo(currentRating1, currentRating2, score1, score2);
|
|
191
|
-
eloRatings.set(choice1.id, newRating1);
|
|
192
|
-
eloRatings.set(choice2.id, newRating2);
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
// After the ELO ratings are computed
|
|
196
|
-
choices.forEach((choice, i) => {
|
|
197
|
-
const eloRating = eloRatings.get(choice.id);
|
|
198
|
-
// Update the Excel sheet with the new ELO rating
|
|
199
|
-
// Note: Adjust the cell reference as needed
|
|
200
|
-
if (eloRating) {
|
|
201
|
-
choicesSheet.getCell(`H${i + 2}`).value = Math.round(eloRating);
|
|
202
|
-
console.log(`Choice ${choice.id} has elo rating ${Math.round(eloRating)}`);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
console.error(`Choice ${choice.id} has no elo rating`);
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
// Generate and upload the workbook to S3
|
|
209
|
-
const buffer = await workbook.xlsx.writeBuffer();
|
|
210
|
-
const filename = `choice_votes_${uuidv4()}.xlsx`;
|
|
211
|
-
console.log(`Uploading choice votes to S3: ${filename}`);
|
|
212
|
-
uploadToS3(workPackage.jobId, `${workPackage.userId}`, filename, workPackage.exportType, buffer, async (error, url) => {
|
|
213
|
-
if (error) {
|
|
214
|
-
console.error("Error uploading choice votes to S3:", error);
|
|
215
|
-
done(error, url);
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
console.log(`Uploaded choice votes to S3: ${url}`);
|
|
219
|
-
await updateUploadJobStatus(workPackage.jobId, 100, {
|
|
220
|
-
reportUrl: url,
|
|
221
|
-
});
|
|
222
|
-
done(undefined, url);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
console.log(`Successfully exported and uploaded choice votes for question ${workPackage.questionId}`);
|
|
226
|
-
}
|
|
227
|
-
catch (error) {
|
|
228
|
-
console.error("Error exporting choice votes:", error);
|
|
229
|
-
await setJobError(workPackage.jobId, "Error exporting choice votes");
|
|
230
|
-
done(error);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
@@ -1,277 +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 getGroupPosts = require("./common_utils.cjs").getGroupPosts;
|
|
9
|
-
const getContactData = require("./common_utils.cjs").getContactData;
|
|
10
|
-
const getAttachmentData = require("./common_utils.cjs").getAttachmentData;
|
|
11
|
-
const getMediaTranscripts = require("./common_utils.cjs").getMediaTranscripts;
|
|
12
|
-
const getPostRatings = require("./common_utils.cjs").getPostRatings;
|
|
13
|
-
const getPostUrl = require("./common_utils.cjs").getPostUrl;
|
|
14
|
-
const getLocation = require("./common_utils.cjs").getLocation;
|
|
15
|
-
const getCategory = require("./common_utils.cjs").getCategory;
|
|
16
|
-
const getUserEmail = require("./common_utils.cjs").getUserEmail;
|
|
17
|
-
const getMediaFormatUrl = require("./common_utils.cjs").getMediaFormatUrl;
|
|
18
|
-
const getMediaURLs = require("./common_utils.cjs").getMediaURLs;
|
|
19
|
-
const getPointsUpOrDown = require("./common_utils.cjs").getPointsUpOrDown;
|
|
20
|
-
const getPointsUp = require("./common_utils.cjs").getPointsUp;
|
|
21
|
-
const getPointsDown = require("./common_utils.cjs").getPointsDown;
|
|
22
|
-
const getTranslatedPoints = require("./common_utils.cjs").getTranslatedPoints;
|
|
23
|
-
const getTranslation = require("./common_utils.cjs").getTranslation;
|
|
24
|
-
const getOrderedPosts = require("./common_utils.cjs").getOrderedPosts;
|
|
25
|
-
const updateJobStatusIfNeeded = require("./common_utils.cjs")
|
|
26
|
-
.updateJobStatusIfNeeded;
|
|
27
|
-
const setJobError = require("./common_utils.cjs").setJobError;
|
|
28
|
-
const uploadToS3 = require("./common_utils.cjs").uploadToS3;
|
|
29
|
-
const sanitizeFilename = require("sanitize-filename");
|
|
30
|
-
const cleanText = (text) => {
|
|
31
|
-
let outText = text;
|
|
32
|
-
outText = outText.replace(/\*/g, '');
|
|
33
|
-
outText = outText.replace(/\?/g, '');
|
|
34
|
-
outText = outText.replace(/:/g, '');
|
|
35
|
-
outText = outText.replace(/\//g, '');
|
|
36
|
-
outText = outText.replace(/\\/g, '');
|
|
37
|
-
outText = outText.replace(/\[/g, '');
|
|
38
|
-
outText = outText.replace(/\]/g, '');
|
|
39
|
-
return outText;
|
|
40
|
-
};
|
|
41
|
-
const formatWorksheet = (worksheet) => {
|
|
42
|
-
worksheet.getRow(1).font = { bold: true };
|
|
43
|
-
// worksheet.properties.defaultRowHeight = 20;
|
|
44
|
-
};
|
|
45
|
-
const getAnswerFor = (text, answers) => {
|
|
46
|
-
for (let i = 0; i < answers.length; i++) {
|
|
47
|
-
if (Object.keys(answers[i])[0] === text)
|
|
48
|
-
return Object.values(answers[i])[0];
|
|
49
|
-
}
|
|
50
|
-
return '';
|
|
51
|
-
};
|
|
52
|
-
async function addUsers(worksheet, model, modelId, asUsersCode, registrationQuestions) {
|
|
53
|
-
let foundAll = false;
|
|
54
|
-
let offset = 0;
|
|
55
|
-
while (!foundAll) {
|
|
56
|
-
const modelResults = await model.findOne({
|
|
57
|
-
attributes: ['id'],
|
|
58
|
-
where: {
|
|
59
|
-
id: modelId,
|
|
60
|
-
},
|
|
61
|
-
include: [
|
|
62
|
-
{
|
|
63
|
-
model: models.User,
|
|
64
|
-
as: asUsersCode,
|
|
65
|
-
attributes: ['id', 'email', 'ssn', 'name', 'private_profile_data', 'created_at'],
|
|
66
|
-
}
|
|
67
|
-
],
|
|
68
|
-
});
|
|
69
|
-
foundAll = true;
|
|
70
|
-
if (modelResults) {
|
|
71
|
-
const users = modelResults[asUsersCode];
|
|
72
|
-
if (users.length === 0) {
|
|
73
|
-
foundAll = true;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
for (let i = 0; i < users.length; i++) {
|
|
77
|
-
let row = {
|
|
78
|
-
email: users[i].email,
|
|
79
|
-
name: users[i].name,
|
|
80
|
-
ssn: users[i].ssn,
|
|
81
|
-
id: users[i].id,
|
|
82
|
-
createdAt: users[i].created_at
|
|
83
|
-
};
|
|
84
|
-
if (registrationQuestions && users[i].private_profile_data && users[i].private_profile_data.registration_answers) {
|
|
85
|
-
const answers = users[i].private_profile_data.registration_answers;
|
|
86
|
-
for (let i = 0; i < registrationQuestions.length; i++) {
|
|
87
|
-
if (registrationQuestions[i].type !== "segment" && registrationQuestions[i].type !== "textDescription") {
|
|
88
|
-
const key = registrationQuestions[i].text;
|
|
89
|
-
const value = getAnswerFor(registrationQuestions[i].text, answers);
|
|
90
|
-
row = _.merge(row, { [key]: value });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
worksheet.addRow(row);
|
|
95
|
-
offset += users.length;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async function addCommunity(workbook, community) {
|
|
102
|
-
let name = community.translatedName ? community.translatedName : community.name;
|
|
103
|
-
name = cleanText(name);
|
|
104
|
-
const worksheet = workbook.addWorksheet(`Community Users ${community.id} ${name}`);
|
|
105
|
-
const columns = [
|
|
106
|
-
{ header: "User Id", key: "id", width: 10 },
|
|
107
|
-
{ header: "Created at", key: "createdAt", width: 15 },
|
|
108
|
-
{ header: "Name", key: "name", width: 30 },
|
|
109
|
-
{ header: "National Id", key: "ssn", width: 15 },
|
|
110
|
-
{ header: "Email", key: "email", width: 40 },
|
|
111
|
-
];
|
|
112
|
-
const registrationQuestions = community.configuration.registrationQuestionsJson;
|
|
113
|
-
if (registrationQuestions) {
|
|
114
|
-
for (let i = 0; i < registrationQuestions.length; i++) {
|
|
115
|
-
if (registrationQuestions[i].type !== "segment" && registrationQuestions[i].type !== "textDescription") {
|
|
116
|
-
try {
|
|
117
|
-
columns.push({
|
|
118
|
-
header: registrationQuestions[i].text,
|
|
119
|
-
key: registrationQuestions[i].text,
|
|
120
|
-
style: { numFmt: '@' },
|
|
121
|
-
alignment: { wrapText: true },
|
|
122
|
-
width: 30
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
catch (ex) {
|
|
126
|
-
log.error(ex);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
worksheet.columns = columns;
|
|
132
|
-
await addUsers(worksheet, models.Community, community.id, "CommunityUsers", registrationQuestions);
|
|
133
|
-
formatWorksheet(worksheet);
|
|
134
|
-
}
|
|
135
|
-
async function addGroup(workbook, group) {
|
|
136
|
-
let name = group.translatedName ? group.translatedName : group.name;
|
|
137
|
-
name = cleanText(name);
|
|
138
|
-
const worksheet = workbook.addWorksheet(`Group Users ${group.id} ${name}`);
|
|
139
|
-
let columns = [
|
|
140
|
-
{ header: "User Id", key: "id", width: 10 },
|
|
141
|
-
{ header: "Created at", key: "createdAt", width: 15 },
|
|
142
|
-
{ header: "Name", key: "name", width: 35 },
|
|
143
|
-
{ header: "National Id", key: "ssn", width: 15 },
|
|
144
|
-
{ header: "Email", key: "email", width: 40 },
|
|
145
|
-
];
|
|
146
|
-
const registrationQuestions = group.configuration.registrationQuestionsJson;
|
|
147
|
-
if (registrationQuestions) {
|
|
148
|
-
for (let i = 0; i < registrationQuestions.length; i++) {
|
|
149
|
-
if (registrationQuestions[i].type !== "segment" && registrationQuestions[i].type !== "textDescription") {
|
|
150
|
-
try {
|
|
151
|
-
columns.push({
|
|
152
|
-
header: registrationQuestions[i].text,
|
|
153
|
-
key: registrationQuestions[i].text,
|
|
154
|
-
width: 30
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
catch (ex) {
|
|
158
|
-
log.error(ex);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
worksheet.columns = columns;
|
|
164
|
-
await addUsers(worksheet, models.Group, group.id, "GroupUsers", registrationQuestions);
|
|
165
|
-
formatWorksheet(worksheet);
|
|
166
|
-
}
|
|
167
|
-
async function exportToXls(options, callback) {
|
|
168
|
-
const community = options.community;
|
|
169
|
-
const groupsLength = community.Groups.length;
|
|
170
|
-
const workbook = new Excel.Workbook();
|
|
171
|
-
workbook.creator = "Your Priorities Report - Automated";
|
|
172
|
-
workbook.created = new Date();
|
|
173
|
-
try {
|
|
174
|
-
await addCommunity(workbook, community);
|
|
175
|
-
for (let i = 0; i < groupsLength; i++) {
|
|
176
|
-
await addGroup(workbook, community.Groups[i]);
|
|
177
|
-
const jobProgress = Math.min(15 + (Math.round(85 / (groupsLength))) * i, 95);
|
|
178
|
-
await models.AcBackgroundJob.update({
|
|
179
|
-
progress: jobProgress,
|
|
180
|
-
}, {
|
|
181
|
-
where: { id: options.jobId },
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
const buffer = await workbook.xlsx.writeBuffer();
|
|
185
|
-
callback(null, buffer);
|
|
186
|
-
}
|
|
187
|
-
catch (error) {
|
|
188
|
-
callback(error);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
const createXlsCommunityUsersReport = (workPackage, callback) => {
|
|
192
|
-
let exportedData, filename;
|
|
193
|
-
async.series([
|
|
194
|
-
(seriesCallback) => {
|
|
195
|
-
models.Community.findOne({
|
|
196
|
-
where: {
|
|
197
|
-
id: workPackage.communityId,
|
|
198
|
-
},
|
|
199
|
-
include: [
|
|
200
|
-
{
|
|
201
|
-
model: models.Group,
|
|
202
|
-
attributes: ['id', 'name', 'configuration']
|
|
203
|
-
}
|
|
204
|
-
],
|
|
205
|
-
attributes: [
|
|
206
|
-
"id",
|
|
207
|
-
"name",
|
|
208
|
-
"description",
|
|
209
|
-
"configuration"
|
|
210
|
-
]
|
|
211
|
-
})
|
|
212
|
-
.then(community => {
|
|
213
|
-
workPackage.community = community;
|
|
214
|
-
const dateString = moment(new Date()).format("DD_MM_YY_HH_mm");
|
|
215
|
-
const communityName = sanitizeFilename(community.name).replace(/ /g, "");
|
|
216
|
-
workPackage.filename =
|
|
217
|
-
"Community_Users_Export_" +
|
|
218
|
-
community.id +
|
|
219
|
-
"_" +
|
|
220
|
-
communityName +
|
|
221
|
-
"_" +
|
|
222
|
-
dateString +
|
|
223
|
-
"." +
|
|
224
|
-
workPackage.fileEnding;
|
|
225
|
-
seriesCallback();
|
|
226
|
-
})
|
|
227
|
-
.catch((error) => {
|
|
228
|
-
seriesCallback(error);
|
|
229
|
-
});
|
|
230
|
-
},
|
|
231
|
-
(seriesCallback) => {
|
|
232
|
-
models.AcBackgroundJob.updateProgress(workPackage.jobId, 5, seriesCallback);
|
|
233
|
-
},
|
|
234
|
-
(seriesCallback) => {
|
|
235
|
-
exportToXls({ jobId: workPackage.jobId, community: workPackage.community }, (error, data) => {
|
|
236
|
-
exportedData = data;
|
|
237
|
-
seriesCallback(error);
|
|
238
|
-
});
|
|
239
|
-
},
|
|
240
|
-
(seriesCallback) => {
|
|
241
|
-
uploadToS3(workPackage.jobId, workPackage.userId, workPackage.filename, workPackage.fileEnding, exportedData, (error, reportUrl) => {
|
|
242
|
-
if (error) {
|
|
243
|
-
seriesCallback(error);
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
console.log(`Updating job 100 with DATA`);
|
|
247
|
-
models.AcBackgroundJob.update({
|
|
248
|
-
progress: 100,
|
|
249
|
-
data: { reportUrl },
|
|
250
|
-
}, {
|
|
251
|
-
where: { id: workPackage.jobId },
|
|
252
|
-
})
|
|
253
|
-
.then(() => {
|
|
254
|
-
seriesCallback();
|
|
255
|
-
})
|
|
256
|
-
.catch((error) => {
|
|
257
|
-
seriesCallback(error);
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
},
|
|
262
|
-
], (error) => {
|
|
263
|
-
if (error) {
|
|
264
|
-
setJobError(workPackage.jobId, "errorXlsCommunityUsersReportGeneration", error, (dbError) => {
|
|
265
|
-
callback(dbError || error);
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
log.info("Done generating report");
|
|
270
|
-
callback();
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
};
|
|
274
|
-
module.exports = {
|
|
275
|
-
createXlsCommunityUsersReport,
|
|
276
|
-
getAnswerFor
|
|
277
|
-
};
|