Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,7 @@ private void SetCommonQueryViewData(Site site, string header)
Site = site;
SetHeader(header);
SelectMenuItem("Compose Query");

ViewData["GuessedUserId"] = Site.GuessUserId(CurrentUser);

ViewData["Tables"] = Site.GetTableInfos();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ private ActionResult ShowCommon(Revision revision, string slug, bool latest)
SetHeader(title);
SelectMenuItem("Queries");

ViewData["GuessedUserId"] = Site.GuessUserId(CurrentUser);

// Need to revamp voting process
int totalVotes = Current.DB.Query<int>(@"
SELECT
Expand Down
47 changes: 0 additions & 47 deletions App/StackExchange.DataExplorer/Models/Site.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Web;
using StackExchange.DataExplorer.Helpers;
using Dapper;
using System.Linq;
Expand Down Expand Up @@ -137,52 +136,6 @@ public void UpdateStats()
Current.DB.Sites.Update(Id, new {TotalQuestions, TotalAnswers, TotalComments, LastPost, TotalUsers, TotalTags });
}

public int? GuessUserId(User user)
{
if (user.IsAnonymous || !AppSettings.GuessUserId) return null;

string cacheKey = "UserIdForSite" + Id + "_" + user.Id;

var currentId = HttpContext.Current.Session[cacheKey] as int?;
if (currentId == null)
{
int? id = FindUserId(user);
if (id != null)
{
HttpContext.Current.Cache[cacheKey] = id;
}
}

currentId = HttpContext.Current.Cache[cacheKey] as int?;
if (currentId == null)
{
HttpContext.Current.Cache[cacheKey] = -1;
}

return currentId != -1 ? currentId : null;
}

private int? FindUserId(User user)
{
if (!user.IsAnonymous && user.Email != null)
{
using (var cnn = GetOpenConnection())
{
string hash = Util.GravatarHash(user.Email);
try
{
return cnn.Query<int?>("select top 1 Id from Users where EmailHash = @hash order by Reputation desc", new {hash}).FirstOrDefault();
}
catch
{
// allow this to fail, its not critical
}
}
}
return null;
}


/// <summary>
/// Get the sites schema
/// </summary>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
</Key>
<Property Name="Id" Type="int" Nullable="false" />
<Property Name="Reputation" Type="int" />
<Property Name="EmailHash" Type="varchar" MaxLength="40" />
<Property Name="CreationDate" Type="datetime" />
<Property Name="DisplayName" Type="nvarchar" MaxLength="40" />
<Property Name="LastAccessDate" Type="datetime" />
Expand Down Expand Up @@ -205,7 +204,6 @@
</Key>
<Property Name="Id" Type="Int32" Nullable="false" />
<Property Name="Reputation" Type="Int32" />
<Property Name="EmailHash" Type="String" MaxLength="40" Unicode="false" FixedLength="false" />
<Property Name="CreationDate" Type="DateTime" />
<Property Name="DisplayName" Type="String" MaxLength="40" Unicode="true" FixedLength="false" />
<Property Name="LastAccessDate" Type="DateTime" />
Expand Down Expand Up @@ -341,7 +339,6 @@
<EntitySetMapping Name="Users"><EntityTypeMapping TypeName="MetaModel.User"><MappingFragment StoreEntitySet="Users">
<ScalarProperty Name="Id" ColumnName="Id" />
<ScalarProperty Name="Reputation" ColumnName="Reputation" />
<ScalarProperty Name="EmailHash" ColumnName="EmailHash" />
<ScalarProperty Name="CreationDate" ColumnName="CreationDate" />
<ScalarProperty Name="DisplayName" ColumnName="DisplayName" />
<ScalarProperty Name="LastAccessDate" ColumnName="LastAccessDate" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@
<Content Include="Views\Shared\Error.cshtml" />
<Content Include="Views\Shared\PageNotFound.cshtml" />
<Content Include="Views\Shared\AboutSite.cshtml" />
<Content Include="Views\Shared\GuessedUserId.cshtml" />
<Content Include="Views\Shared\Menu.cshtml" />
<Content Include="Views\Shared\PageSizer.cshtml" />
<Content Include="Views\Shared\QueryVoting.cshtml" />
Expand Down
10 changes: 0 additions & 10 deletions App/StackExchange.DataExplorer/Views/Shared/GuessedUserId.cshtml

This file was deleted.

2 changes: 1 addition & 1 deletion App/StackExchange.DataExplorer/Views/Shared/Master.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<script>
DataExplorer.init({
'User.id': @(Current.User.IsAnonymous ? "null" : Current.User.Id.ToString()),
'User.guessedID': @(ViewData["GuessedUserId"] ?? "null"),
'User.guessedID': null,
'User.hideSchema': @Current.User.HideSchema.ToString().ToLower(),
'User.isAuthenticated': @((!Current.User.IsAnonymous).ToString().ToLower()),
'Site.id': @(Current.Controller.Site != null ? Current.Controller.Site.Id.ToString() : "null"),
Expand Down