<commit_before><%
  db = sql_drivername = sql_datasource = nil
  if_link("postgresql") do |database|
    db = database
    db.if_p("postgres.config", "pgpool.users", "pgpool.databases") do |config, users, databases|
      sql_drivername = "postgres"
      host = db.instances.first.address
      host = "localhost" if host == spec.address
      port = config["port"] || 6432
      nonadmin_user = users.find { |u| !u[:admin] && !u["admin"] } || users.first
      username = nonadmin_user["username"]
      password = nonadmin_user["password"]
      dbname = databases.first["name"]
      sql_datasource = "postgres://#{username}:#{password}@#{host}:#{port}/#{dbname}?sslmode=disable&connect_timeout=10"
    end
  end
-%>
{
    "ServiceSettings": {
        "SiteURL": "<%= p("mattermost.ServiceSettings.SiteURL") %>",
        "LicenseFileLocation": "<%= p("mattermost.License") == "" ? "" : "/var/vcap/jobs/mattermost/config/license" %>",
        "ListenAddress": "<%= p("mattermost.ServiceSettings.ListenAddress") %>",
        "ConnectionSecurity": "<%= p("mattermost.ServiceSettings.ConnectionSecurity") %>",
        "TLSCertFile": "<%= p("mattermost.ServiceSettings.TLSCertFile") %>",
        "TLSKeyFile": "<%= p("mattermost.ServiceSettings.TLSKeyFile") %>",
        "UseLetsEncrypt": false,
        "LetsEncryptCertificateCacheFile": "./config/letsencrypt.cache",
        "Forward80To443": <%= p("mattermost.ServiceSettings.Forward80To443") %>,
        "ReadTimeout": 300,
        "WriteTimeout": 300,
        "MaximumLoginAttempts": <%= p("mattermost.ServiceSettings.MaximumLoginAttempts") %>,
        "GoroutineHealthThreshold": <%= p("mattermost.ServiceSettings.GoroutineHealthThreshold") %>,
        "GoogleDeveloperKey": "<%= p("mattermost.ServiceSettings.GoogleDeveloperKey") %>",
        "EnableOAuthServiceProvider": <%= p("mattermost.ServiceSettings.EnableOAuthServiceProvider") %>,
        "EnableIncomingWebhooks": <%= p("mattermost.ServiceSettings.EnableIncomingWebhooks") %>,
        "EnableOutgoingWebhooks": <%= p("mattermost.ServiceSettings.EnableOutgoingWebhooks") %>,
        "EnableCommands": <%= p("mattermost.ServiceSettings.EnableCommands") %>,
        "EnableOnlyAdminIntegrations": <%= p("mattermost.ServiceSettings.EnableOnlyAdminIntegrations") %>,
        "EnablePostUsernameOverride": <%= p("mattermost.ServiceSettings.EnablePostUsernameOverride") %>,
        "EnablePostIconOverride": <%= p("mattermost.ServiceSettings.EnablePostIconOverride") %>,
        "EnableLinkPreviews": <%= p("mattermost.ServiceSettings.EnableLinkPreviews") %>,
        "EnableTesting": <%= p("mattermost.ServiceSettings.EnableTesting") %>,
        "EnableDeveloper": <%= p("mattermost.ServiceSettings.EnableDeveloper") %>,
        "EnableSecurityFixAlert": <%= p("mattermost.ServiceSettings.EnableSecurityFixAlert") %>,
        "EnableInsecureOutgoingConnections": <%= p("mattermost.ServiceSettings.EnableInsecureOutgoingConnections") %>,
        "EnableMultifactorAuthentication": <%= p("mattermost.ServiceSettings.EnableMultifactorAuthentication") %>,
        "EnforceMultifactorAuthentication": <%= p("mattermost.ServiceSettings.EnforceMultifactorAuthentication") %>,
        "AllowCorsFrom": "<%= p("mattermost.ServiceSettings.AllowCorsFrom") %>",
        "SessionLengthWebInDays": <%= p("mattermost.ServiceSettings.SessionLengthWebInDays") %>,
        "SessionLengthMobileInDays": <%= p("mattermost.ServiceSettings.SessionLengthMobileInDays") %>,
        "SessionLengthSSOInDays": <%= p("mattermost.ServiceSettings.SessionLengthSSOInDays") %>,
        "SessionCacheInMinutes": <%= p("mattermost.ServiceSettings.SessionCacheInMinutes") %>,
        "WebsocketSecurePort": <%= p("mattermost.ServiceSettings.WebsocketSecurePort") %>,
        "WebsocketPort": <%= p("mattermost.ServiceSettings.WebsocketPort") %>,
        "WebserverMode": "gzip",
        "EnableCustomEmoji": <%= p("mattermost.ServiceSettings.EnableCustomEmoji") %>,
        "RestrictCustomEmojiCreation": "<%= p("mattermost.ServiceSettings.RestrictCustomEmojiCreation") %>",
        "RestrictPostDelete": "<%= p("mattermost.ServiceSettings.RestrictPostDelete") %>",
        "AllowEditPost": "<%= p("mattermost.ServiceSettings.AllowEditPost") %>",
        "PostEditTimeLimit": <%= p("mattermost.ServiceSettings.PostEditTimeLimit") %>,
        "TimeBetweenUserTypingUpdatesMilliseconds": 5000,
        "EnablePostSearch": true,
        "EnableUserTypingMessages": true,
        "EnableUserStatuses": true,
        "ClusterLogTimeoutMilliseconds": 2000,
        "EnableEmojiPicker": <%= p("mattermost.ServiceSettings.EnableEmojiPicker") %>,
        "EnableChannelViewedMessages": <%= p("mattermost.ServiceSettings.EnableChannelViewedMessages") %>,
        "EnableAPIv3": <%= p("mattermost.ServiceSettings.EnableAPIv3") %>,
        "EnableUserAccessTokens": <%= p("mattermost.ServiceSettings.EnableUserAccessTokens") %>,
        "AllowedUntrustedInternalConnections": "<%= p("mattermost.ServiceSettings.AllowedUntrustedInternalConnections") %>",
        "SessionIdleTimeoutInMinutes": <%= p("mattermost.ServiceSettings.SessionIdleTimeoutInMinutes") %>,
        "CloseUnusedDirectMessages": <%= p("mattermost.ServiceSettings.CloseUnusedDirectMessages") %>,
        "EnablePreviewFeatures": <%= p("mattermost.ServiceSettings.EnablePreviewFeatures") %>,
        "ExperimentalEnableAuthenticationTransfer": <%= p("mattermost.ServiceSettings.ExperimentalEnableAuthenticationTransfer") %>,
        "EnableTutorial": <%= p("mattermost.ServiceSettings.EnableTutorial") %>,
        <% if_p("mattermost.ServiceSettings.ImageProxyType") do |proxyType| %>
        "ImageProxyType": "<%= p("proxyType") %>",
        "ImageProxyOptions":" <%= p("mattermost.ServiceSettings.ImageProxyOptions") %>",
        "ImageProxyURL": "<%= p("mattermost.ServiceSettings.ImageProxyURL") %>",
        <% end %>
        "ExperimentalGroupUnreadChannels": "<%= p("mattermost.ServiceSettings.ExperimentalGroupUnreadChannels") %>",
        "ExperimentalEnableDefaultChannelLeaveJoinMessages":  <%= p("mattermost.ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages") %>,
        "EnableAPITeamDeletion": <%= p("mattermost.ServiceSettings.EnableAPITeamDeletion") %>,
        "ExperimentalEnableHardenedMode": <%= p("mattermost.ServiceSettings.ExperimentalEnableHardenedMode") %>,
        "ExperimentalLimitClientConfig": <%= p("mattermost.ServiceSettings.ExperimentalLimitClientConfig") %>,
        "EnableGifPicker": <%= p("mattermost.ServiceSettings.EnableGifPicker") %>,
        "GfycatApiKey": "<%= p("mattermost.ServiceSettings.GfycatApiKey") %>",
        "GfycatApiSecret": "<%= p("mattermost.ServiceSettings.GfycatApiSecret") %>",
        "EnableEmailInvitations": <%= p("mattermost.ServiceSettings.EnableEmailInvitations") %>,
        "CorsExposedHeaders": "<%= p("mattermost.ServiceSettings.CorsExposedHeaders") %>",
        "CorsAllowCredentials": "<%= p("mattermost.ServiceSettings.CorsAllowCredentials") %>",
        "CorsDebug": "<%= p("mattermost.ServiceSettings.CorsDebug") %>"
    },
    "TeamSettings": {
        "SiteName": "<%= p("mattermost.TeamSettings.SiteName") %>",
        "EnableUserCreation": <%= p("mattermost.TeamSettings.EnableUserCreation") %>,
        "EnableTeamCreation": <%= p("mattermost.TeamSettings.EnableTeamCreation") %>,
        "MaxUsersPerTeam": <%= p("mattermost.TeamSettings.MaxUsersPerTeam") %>,
        "MaxChannelsPerTeam": <%= p("mattermost.TeamSettings.MaxChannelsPerTeam") %>,
        "MaxNotificationsPerChannel": <%= p("mattermost.TeamSettings.MaxNotificationsPerChannel") %>,
        "EnableOpenServer": <%= p("mattermost.TeamSettings.EnableOpenServer") %>,
        "RestrictCreationToDomains": "<%= p("mattermost.TeamSettings.RestrictCreationToDomains") %>",
        "EnableCustomBrand": <%= p("mattermost.TeamSettings.EnableCustomBrand") %>,
        "CustomBrandText": "<%= p("mattermost.TeamSettings.CustomBrandText") %>",
        "CustomDescriptionText": "<%= p("mattermost.TeamSettings.CustomDescriptionText") %>",
        "RestrictDirectMessage": "any",
        "RestrictTeamInvite": "<%= p("mattermost.TeamSettings.RestrictTeamInvite") %>",
        "RestrictPublicChannelManagement": "<%= p("mattermost.TeamSettings.RestrictPublicChannelManagement") %>",
        "RestrictPrivateChannelManagement": "<%= p("mattermost.TeamSettings.RestrictPrivateChannelManagement") %>",
        "RestrictPublicChannelCreation": "<%= p("mattermost.TeamSettings.RestrictPublicChannelCreation") %>",
        "RestrictPrivateChannelCreation": "<%= p("mattermost.TeamSettings.RestrictPrivateChannelCreation") %>",
        "RestrictPublicChannelDeletion": "<%= p("mattermost.TeamSettings.RestrictPublicChannelDeletion") %>",
        "RestrictPrivateChannelDeletion": "<%= p("mattermost.TeamSettings.RestrictPrivateChannelDeletion") %>",
        "RestrictPrivateChannelManageMembers": "<%= p("mattermost.TeamSettings.RestrictPrivateChannelManageMembers") %>",
        "UserStatusAwayTimeout": 300,
        "TeammateNameDisplay": "<%= p("mattermost.TeamSettings.TeammateNameDisplay") %>",
        "EnableXToLeaveChannelsFromLHS": <%= p("mattermost.TeamSettings.EnableXToLeaveChannelsFromLHS") %>,
        "EnableConfirmNotificationsToChannel": <%= p("mattermost.TeamSettings.EnableConfirmNotificationsToChannel")%>,
        "ExperimentalPrimaryTeam": "<%= p("mattermost.TeamSettings.ExperimentalPrimaryTeam") %>",
        "ExperimentalEnableAutomaticReplies": <%= p("mattermost.TeamSettings.ExperimentalEnableAutomaticReplies") %>,
        "ExperimentalHideTownSquareinLHS": <%= p("mattermost.TeamSettings.ExperimentalHideTownSquareinLHS") %>,
        "ViewArchivedChannels": <%= p("mattermost.TeamSettings.ViewArchivedChannels") %>,
        "ExperimentalDefaultChannels": <%= p("mattermost.TeamSettings.ExperimentalDefaultChannels") %>
    },

    "SqlSettings": {
        "DriverName": "<%= p("mattermost.SqlSettings.DriverName", sql_drivername) %>",
        "DataSource": "<%= p("mattermost.SqlSettings.DataSource", sql_datasource) %>",
        "DataSourceReplicas": [],<commit_msg>Syntax fix<commit_after><%
  db = sql_drivername = sql_datasource = nil
  if_link("postgresql") do |database|
    db = database
    db.if_p("postgres.config", "pgpool.users", "pgpool.databases") do |config, users, databases|
      sql_drivername = "postgres"
      host = db.instances.first.address
      host = "localhost" if host == spec.address
      port = config["port"] || 6432
      nonadmin_user = users.find { |u| !u[:admin] && !u["admin"] } || users.first
      username = nonadmin_user["username"]
      password = nonadmin_user["password"]
      dbname = databases.first["name"]
      sql_datasource = "postgres://#{username}:#{password}@#{host}:#{port}/#{dbname}?sslmode=disable&connect_timeout=10"
    end
  end
-%>
{
    "ServiceSettings": {
        "SiteURL": "<%= p("mattermost.ServiceSettings.SiteURL") %>",
        "LicenseFileLocation": "<%= p("mattermost.License") == "" ? "" : "/var/vcap/jobs/mattermost/config/license" %>",
        "ListenAddress": "<%= p("mattermost.ServiceSettings.ListenAddress") %>",
        "ConnectionSecurity": "<%= p("mattermost.ServiceSettings.ConnectionSecurity") %>",
        "TLSCertFile": "<%= p("mattermost.ServiceSettings.TLSCertFile") %>",
        "TLSKeyFile": "<%= p("mattermost.ServiceSettings.TLSKeyFile") %>",
        "UseLetsEncrypt": false,
        "LetsEncryptCertificateCacheFile": "./config/letsencrypt.cache",
        "Forward80To443": <%= p("mattermost.ServiceSettings.Forward80To443") %>,
        "ReadTimeout": 300,
        "WriteTimeout": 300,
        "MaximumLoginAttempts": <%= p("mattermost.ServiceSettings.MaximumLoginAttempts") %>,
        "GoroutineHealthThreshold": <%= p("mattermost.ServiceSettings.GoroutineHealthThreshold") %>,
        "GoogleDeveloperKey": "<%= p("mattermost.ServiceSettings.GoogleDeveloperKey") %>",
        "EnableOAuthServiceProvider": <%= p("mattermost.ServiceSettings.EnableOAuthServiceProvider") %>,
        "EnableIncomingWebhooks": <%= p("mattermost.ServiceSettings.EnableIncomingWebhooks") %>,
        "EnableOutgoingWebhooks": <%= p("mattermost.ServiceSettings.EnableOutgoingWebhooks") %>,
        "EnableCommands": <%= p("mattermost.ServiceSettings.EnableCommands") %>,
        "EnableOnlyAdminIntegrations": <%= p("mattermost.ServiceSettings.EnableOnlyAdminIntegrations") %>,
        "EnablePostUsernameOverride": <%= p("mattermost.ServiceSettings.EnablePostUsernameOverride") %>,
        "EnablePostIconOverride": <%= p("mattermost.ServiceSettings.EnablePostIconOverride") %>,
        "EnableLinkPreviews": <%= p("mattermost.ServiceSettings.EnableLinkPreviews") %>,
        "EnableTesting": <%= p("mattermost.ServiceSettings.EnableTesting") %>,
        "EnableDeveloper": <%= p("mattermost.ServiceSettings.EnableDeveloper") %>,
        "EnableSecurityFixAlert": <%= p("mattermost.ServiceSettings.EnableSecurityFixAlert") %>,
        "EnableInsecureOutgoingConnections": <%= p("mattermost.ServiceSettings.EnableInsecureOutgoingConnections") %>,
        "EnableMultifactorAuthentication": <%= p("mattermost.ServiceSettings.EnableMultifactorAuthentication") %>,
        "EnforceMultifactorAuthentication": <%= p("mattermost.ServiceSettings.EnforceMultifactorAuthentication") %>,
        "AllowCorsFrom": "<%= p("mattermost.ServiceSettings.AllowCorsFrom") %>",
        "SessionLengthWebInDays": <%= p("mattermost.ServiceSettings.SessionLengthWebInDays") %>,
        "SessionLengthMobileInDays": <%= p("mattermost.ServiceSettings.SessionLengthMobileInDays") %>,
        "SessionLengthSSOInDays": <%= p("mattermost.ServiceSettings.SessionLengthSSOInDays") %>,
        "SessionCacheInMinutes": <%= p("mattermost.ServiceSettings.SessionCacheInMinutes") %>,
        "WebsocketSecurePort": <%= p("mattermost.ServiceSettings.WebsocketSecurePort") %>,
        "WebsocketPort": <%= p("mattermost.ServiceSettings.WebsocketPort") %>,
        "WebserverMode": "gzip",
        "EnableCustomEmoji": <%= p("mattermost.ServiceSettings.EnableCustomEmoji") %>,
        "RestrictCustomEmojiCreation": "<%= p("mattermost.ServiceSettings.RestrictCustomEmojiCreation") %>",
        "RestrictPostDelete": "<%= p("mattermost.ServiceSettings.RestrictPostDelete") %>",
        "AllowEditPost": "<%= p("mattermost.ServiceSettings.AllowEditPost") %>",
        "PostEditTimeLimit": <%= p("mattermost.ServiceSettings.PostEditTimeLimit") %>,
        "TimeBetweenUserTypingUpdatesMilliseconds": 5000,
        "EnablePostSearch": true,
        "EnableUserTypingMessages": true,
        "EnableUserStatuses": true,
        "ClusterLogTimeoutMilliseconds": 2000,
        "EnableEmojiPicker": <%= p("mattermost.ServiceSettings.EnableEmojiPicker") %>,
        "EnableChannelViewedMessages": <%= p("mattermost.ServiceSettings.EnableChannelViewedMessages") %>,
        "EnableAPIv3": <%= p("mattermost.ServiceSettings.EnableAPIv3") %>,
        "EnableUserAccessTokens": <%= p("mattermost.ServiceSettings.EnableUserAccessTokens") %>,
        "AllowedUntrustedInternalConnections": "<%= p("mattermost.ServiceSettings.AllowedUntrustedInternalConnections") %>",
        "SessionIdleTimeoutInMinutes": <%= p("mattermost.ServiceSettings.SessionIdleTimeoutInMinutes") %>,
        "CloseUnusedDirectMessages": <%= p("mattermost.ServiceSettings.CloseUnusedDirectMessages") %>,
        "EnablePreviewFeatures": <%= p("mattermost.ServiceSettings.EnablePreviewFeatures") %>,
        "ExperimentalEnableAuthenticationTransfer": <%= p("mattermost.ServiceSettings.ExperimentalEnableAuthenticationTransfer") %>,
        "EnableTutorial": <%= p("mattermost.ServiceSettings.EnableTutorial") %>,
        <% if_p("mattermost.ServiceSettings.ImageProxyType") do |proxyType| %>
        "ImageProxyType": "<%= p("proxyType") %>",
        "ImageProxyOptions":" <%= p("mattermost.ServiceSettings.ImageProxyOptions") %>",
        "ImageProxyURL": "<%= p("mattermost.ServiceSettings.ImageProxyURL") %>",
        <% end %>
        "ExperimentalGroupUnreadChannels": "<%= p("mattermost.ServiceSettings.ExperimentalGroupUnreadChannels") %>",
        "ExperimentalEnableDefaultChannelLeaveJoinMessages":  <%= p("mattermost.ServiceSettings.ExperimentalEnableDefaultChannelLeaveJoinMessages") %>,
        "EnableAPITeamDeletion": <%= p("mattermost.ServiceSettings.EnableAPITeamDeletion") %>,
        "ExperimentalEnableHardenedMode": <%= p("mattermost.ServiceSettings.ExperimentalEnableHardenedMode") %>,
        "ExperimentalLimitClientConfig": <%= p("mattermost.ServiceSettings.ExperimentalLimitClientConfig") %>,
        "EnableGifPicker": <%= p("mattermost.ServiceSettings.EnableGifPicker") %>,
        "GfycatApiKey": "<%= p("mattermost.ServiceSettings.GfycatApiKey") %>",
        "GfycatApiSecret": "<%= p("mattermost.ServiceSettings.GfycatApiSecret") %>",
        "EnableEmailInvitations": <%= p("mattermost.ServiceSettings.EnableEmailInvitations") %>,
        "CorsExposedHeaders": "<%= p("mattermost.ServiceSettings.CorsExposedHeaders") %>",
        "CorsAllowCredentials": "<%= p("mattermost.ServiceSettings.CorsAllowCredentials") %>",
        "CorsDebug": "<%= p("mattermost.ServiceSettings.CorsDebug") %>"
    },
    "TeamSettings": {
        "SiteName": "<%= p("mattermost.TeamSettings.SiteName") %>",
        "EnableUserCreation": <%= p("mattermost.TeamSettings.EnableUserCreation") %>,
        "EnableTeamCreation": <%= p("mattermost.TeamSettings.EnableTeamCreation") %>,
        "MaxUsersPerTeam": <%= p("mattermost.TeamSettings.MaxUsersPerTeam") %>,
        "MaxChannelsPerTeam": <%= p("mattermost.TeamSettings.MaxChannelsPerTeam") %>,
        "MaxNotificationsPerChannel": <%= p("mattermost.TeamSettings.MaxNotificationsPerChannel") %>,
        "EnableOpenServer": <%= p("mattermost.TeamSettings.EnableOpenServer") %>,
        "RestrictCreationToDomains": "<%= p("mattermost.TeamSettings.RestrictCreationToDomains") %>",
        "EnableCustomBrand": <%= p("mattermost.TeamSettings.EnableCustomBrand") %>,
        "CustomBrandText": "<%= p("mattermost.TeamSettings.CustomBrandText") %>",
        "CustomDescriptionText": "<%= p("mattermost.TeamSettings.CustomDescriptionText") %>",
        "RestrictDirectMessage": "any",
        "RestrictTeamInvite": "<%= p("mattermost.TeamSettings.RestrictTeamInvite") %>",
        "RestrictPublicChannelManagement": "<%= p("mattermost.TeamSettings.RestrictPublicChannelManagement") %>",
        "RestrictPrivateChannelManagement": "<%= p("mattermost.TeamSettings.RestrictPrivateChannelManagement") %>",
        "RestrictPublicChannelCreation": "<%= p("mattermost.TeamSettings.RestrictPublicChannelCreation") %>",
        "RestrictPrivateChannelCreation": "<%= p("mattermost.TeamSettings.RestrictPrivateChannelCreation") %>",
        "RestrictPublicChannelDeletion": "<%= p("mattermost.TeamSettings.RestrictPublicChannelDeletion") %>",
        "RestrictPrivateChannelDeletion": "<%= p("mattermost.TeamSettings.RestrictPrivateChannelDeletion") %>",
        "RestrictPrivateChannelManageMembers": "<%= p("mattermost.TeamSettings.RestrictPrivateChannelManageMembers") %>",
        "UserStatusAwayTimeout": 300,
        "TeammateNameDisplay": "<%= p("mattermost.TeamSettings.TeammateNameDisplay") %>",
        "EnableXToLeaveChannelsFromLHS": <%= p("mattermost.TeamSettings.EnableXToLeaveChannelsFromLHS") %>,
        "EnableConfirmNotificationsToChannel": <%= p("mattermost.TeamSettings.EnableConfirmNotificationsToChannel")%>,
        "ExperimentalPrimaryTeam": "<%= p("mattermost.TeamSettings.ExperimentalPrimaryTeam") %>",
        "ExperimentalEnableAutomaticReplies": <%= p("mattermost.TeamSettings.ExperimentalEnableAutomaticReplies") %>,
        "ExperimentalHideTownSquareinLHS": <%= p("mattermost.TeamSettings.ExperimentalHideTownSquareinLHS") %>,
        "ViewArchivedChannels": <%= p("mattermost.TeamSettings.ViewArchivedChannels") %>,
        "ExperimentalDefaultChannels": "<%= p("mattermost.TeamSettings.ExperimentalDefaultChannels") %>"
    },

    "SqlSettings": {
        "DriverName": "<%= p("mattermost.SqlSettings.DriverName", sql_drivername) %>",
        "DataSource": "<%= p("mattermost.SqlSettings.DataSource", sql_datasource) %>",
        "DataSourceReplicas": [],
{'fraction_non_alphanumeric': 0.16439172085173973, 'fraction_numerical': 0.0034744626991611654, 'mean_word_length': 5.245505269683819, 'pattern_counts': {'":': 212, '<': 189, '<?xml version=': 0, '>': 189, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3831000', 'n_tokens_mistral': 6088, 'n_tokens_neox': 5501, 'n_words': 521}