mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Refactor struct's time to remove unnecessary memory usage (#3142)
* refactor struct's time to remove unnecessary memory usage * use AsTimePtr simple code * fix tests * fix time compare * fix template on gpg * use AddDuration instead of Add
This commit is contained in:
@@ -29,8 +29,8 @@
|
||||
<td><a href="{{AppSubUrl}}/admin/auths/{{.ID}}">{{.Name}}</a></td>
|
||||
<td>{{.TypeName}}</td>
|
||||
<td><i class="fa fa{{if .IsActived}}-check{{end}}-square-o"></i></td>
|
||||
<td><span class="poping up" data-content="{{DateFmtLong .Updated}}" data-variation="tiny">{{DateFmtShort .Updated}}</span></td>
|
||||
<td><span class="poping up" data-content="{{DateFmtLong .Created}}" data-variation="tiny">{{DateFmtShort .Created}}</span></td>
|
||||
<td><span class="poping up" data-content="{{.UpdatedUnix.FormatShort}}" data-variation="tiny">{{.UpdatedUnix.FormatShort}}</span></td>
|
||||
<td><span class="poping up" data-content="{{.CreatedUnix.FormatLong}}" data-variation="tiny">{{.CreatedUnix.FormatShort}}</span></td>
|
||||
<td><a href="{{AppSubUrl}}/admin/auths/{{.ID}}"><i class="fa fa-pencil-square-o"></i></a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
|
@@ -49,8 +49,8 @@
|
||||
<tr>
|
||||
<td>{{.PID}}</td>
|
||||
<td>{{.Description}}</td>
|
||||
<td>{{DateFmtLong .Start}}</td>
|
||||
<td>{{TimeSince .Start $.Lang}}</td>
|
||||
<td>{{.Start.FormatLong}}</td>
|
||||
<td>{{TimeSinceUnix .Start $.Lang}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
|
@@ -29,7 +29,7 @@
|
||||
<td>{{.ID}}</td>
|
||||
<td>{{$.i18n.Tr .TrStr}}</td>
|
||||
<td>{{SubStr .Description 0 120}}...</td>
|
||||
<td><span class="poping up" data-content="{{.Created}}" data-variation="inverted tiny">{{DateFmtShort .Created}}</span></td>
|
||||
<td><span class="poping up" data-content="{{.CreatedUnix.AsTime}}" data-variation="inverted tiny">{{.CreatedUnix.FormatShort}}</span></td>
|
||||
<td><a href="#"><i class="browser icon view-detail" data-content="{{.Description}}"></i></a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
|
@@ -33,7 +33,7 @@
|
||||
<td>{{.NumTeams}}</td>
|
||||
<td>{{.NumMembers}}</td>
|
||||
<td>{{.NumRepos}}</td>
|
||||
<td><span title="{{DateFmtLong .Created}}">{{DateFmtShort .Created}}</span></td>
|
||||
<td><span title="{{.CreatedUnix.FormatLong}}">{{.CreatedUnix.FormatShort}}</span></td>
|
||||
<td><a href="{{AppSubUrl}}/org/{{.Name}}/settings"><i class="fa fa-pencil-square-o"></i></a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
|
@@ -36,7 +36,7 @@
|
||||
<td>{{.NumStars}}</td>
|
||||
<td>{{.NumIssues}}</td>
|
||||
<td>{{SizeFmt .Size}}</td>
|
||||
<td><span title="{{DateFmtLong .Created}}">{{DateFmtShort .Created}}</span></td>
|
||||
<td><span title="{{.CreatedUnix.FormatLong}}">{{.CreatedUnix.FormatShort}}</span></td>
|
||||
<td><a class="delete-button" href="" data-url="{{$.Link}}/delete?page={{$.Page.Current}}" data-id="{{.ID}}"><i class="trash icon text red"></i></a></td>
|
||||
</tr>
|
||||
{{end}}
|
||||
|
@@ -36,9 +36,9 @@
|
||||
<td><i class="fa fa{{if .IsActive}}-check{{end}}-square-o"></i></td>
|
||||
<td><i class="fa fa{{if .IsAdmin}}-check{{end}}-square-o"></i></td>
|
||||
<td>{{.NumRepos}}</td>
|
||||
<td><span title="{{DateFmtLong .Created}}">{{DateFmtShort .Created }}</span></td>
|
||||
<td><span title="{{.CreatedUnix.FormatLong}}">{{.CreatedUnix.FormatShort}}</span></td>
|
||||
{{if .LastLoginUnix}}
|
||||
<td><span title="{{DateFmtLong .LastLogin}}">{{DateFmtShort .LastLogin }}</span></td>
|
||||
<td><span title="{{.LastLoginUnix.FormatLong}}">{{.LastLoginUnix.FormatShort}}</span></td>
|
||||
{{else}}
|
||||
<td><span>{{$.i18n.Tr "admin.users.never_login"}}</span></td>
|
||||
{{end}}
|
||||
|
@@ -18,7 +18,7 @@
|
||||
<i class="octicon octicon-link"></i>
|
||||
<a href="{{.Website}}" rel="nofollow">{{.Website}}</a>
|
||||
{{end}}
|
||||
<i class="octicon octicon-clock"></i> {{$.i18n.Tr "user.join_on"}} {{DateFmtShort .Created}}
|
||||
<i class="octicon octicon-clock"></i> {{$.i18n.Tr "user.join_on"}} {{.CreatedUnix.FormatShort}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
</div>
|
||||
{{if .DescriptionHTML}}<p class="has-emoji">{{.DescriptionHTML}}</p>{{end}}
|
||||
<p class="time">{{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Updated $.i18n.Lang}}</p>
|
||||
<p class="time">{{$.i18n.Tr "org.repo_updated"}} {{TimeSinceUnix .UpdatedUnix $.i18n.Lang}}</p>
|
||||
</div>
|
||||
{{else}}
|
||||
<div>
|
||||
|
@@ -18,7 +18,7 @@
|
||||
<i class="octicon octicon-mail"></i>
|
||||
<a href="mailto:{{.Email}}" rel="nofollow">{{.Email}}</a>
|
||||
{{end}}
|
||||
<i class="octicon octicon-clock"></i> {{$.i18n.Tr "user.join_on"}} {{DateFmtShort .Created}}
|
||||
<i class="octicon octicon-clock"></i> {{$.i18n.Tr "user.join_on"}} {{.CreatedUnix.FormatShort}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -86,7 +86,7 @@
|
||||
{{if not .IsTag}}
|
||||
<a class="title has-emoji" href="{{$.Repository.HTMLURL}}/src/{{.TagName}}">{{.Title}}</a>
|
||||
{{end}}
|
||||
{{TimeSince .Created $.Lang}}
|
||||
{{TimeSinceUnix .CreatedUnix $.Lang}}
|
||||
</p>
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -102,7 +102,7 @@
|
||||
<p class="desc">
|
||||
<div class="ui purple label">{{$.i18n.Tr "repo.activity.merged_prs_label"}}</div>
|
||||
#{{.Index}} <a class="title has-emoji" href="{{$.Repository.HTMLURL}}/pulls/{{.Index}}">{{.Issue.Title}}</a>
|
||||
{{TimeSince .Merged $.Lang}}
|
||||
{{TimeSinceUnix .MergedUnix $.Lang}}
|
||||
</p>
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -118,7 +118,7 @@
|
||||
<p class="desc">
|
||||
<div class="ui green label">{{$.i18n.Tr "repo.activity.opened_prs_label"}}</div>
|
||||
#{{.Index}} <a class="title has-emoji" href="{{$.Repository.HTMLURL}}/pulls/{{.Index}}">{{.Issue.Title}}</a>
|
||||
{{TimeSince .Issue.Created $.Lang}}
|
||||
{{TimeSinceUnix .Issue.CreatedUnix $.Lang}}
|
||||
</p>
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -134,7 +134,7 @@
|
||||
<p class="desc">
|
||||
<div class="ui red label">{{$.i18n.Tr "repo.activity.closed_issue_label"}}</div>
|
||||
#{{.Index}} <a class="title has-emoji" href="{{$.Repository.HTMLURL}}/issues/{{.Index}}">{{.Title}}</a>
|
||||
{{TimeSince .Updated $.Lang}}
|
||||
{{TimeSinceUnix .UpdatedUnix $.Lang}}
|
||||
</p>
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -150,7 +150,7 @@
|
||||
<p class="desc">
|
||||
<div class="ui green label">{{$.i18n.Tr "repo.activity.new_issue_label"}}</div>
|
||||
#{{.Index}} <a class="title has-emoji" href="{{$.Repository.HTMLURL}}/issues/{{.Index}}">{{.Title}}</a>
|
||||
{{TimeSince .Created $.Lang}}
|
||||
{{TimeSinceUnix .CreatedUnix $.Lang}}
|
||||
</p>
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -174,7 +174,7 @@
|
||||
{{else}}
|
||||
<a class="title has-emoji" href="{{$.Repository.HTMLURL}}/issues/{{.Index}}">{{.Title}}</a>
|
||||
{{end}}
|
||||
{{TimeSince .Updated $.Lang}}
|
||||
{{TimeSinceUnix .UpdatedUnix $.Lang}}
|
||||
</p>
|
||||
{{end}}
|
||||
</div>
|
||||
|
@@ -39,7 +39,7 @@
|
||||
<td>
|
||||
{{if .IsDeleted}}
|
||||
<s>{{.Name}}</s>
|
||||
<p class="time">{{$.i18n.Tr "repo.branch.deleted_by" .DeletedBranch.DeletedBy.Name}} {{TimeSince .DeletedBranch.Deleted $.i18n.Lang}}</p>
|
||||
<p class="time">{{$.i18n.Tr "repo.branch.deleted_by" .DeletedBranch.DeletedBy.Name}} {{TimeSinceUnix .DeletedBranch.DeletedUnix $.i18n.Lang}}</p>
|
||||
{{else}}
|
||||
{{.Name}}
|
||||
<p class="time">{{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Commit.Committer.When $.i18n.Lang}}</p>
|
||||
|
@@ -163,7 +163,7 @@
|
||||
|
||||
<div class="issue list">
|
||||
{{range .Issues}}
|
||||
{{ $timeStr:= TimeSince .Created $.Lang }}
|
||||
{{ $timeStr:= TimeSinceUnix .CreatedUnix $.Lang }}
|
||||
<li class="item">
|
||||
<div class="ui checkbox issue-checkbox">
|
||||
<input type="checkbox" data-issue-id={{.ID}}></input>
|
||||
|
@@ -50,7 +50,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="meta">
|
||||
{{ $closedDate:= TimeSince .ClosedDate $.Lang }}
|
||||
{{ $closedDate:= TimeSinceUnix .ClosedDateUnix $.Lang }}
|
||||
{{if .IsClosed}}
|
||||
<span class="octicon octicon-clock"></span> {{$.i18n.Tr "repo.milestones.closed" $closedDate|Str2html}}
|
||||
{{else}}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
{{template "repo/issue/view_title" .}}
|
||||
{{end}}
|
||||
|
||||
{{ $createdStr:= TimeSince .Issue.Created $.Lang }}
|
||||
{{ $createdStr:= TimeSinceUnix .Issue.CreatedUnix $.Lang }}
|
||||
<div class="twelve wide column comment-list">
|
||||
<ui class="ui comments">
|
||||
<div class="comment">
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{{range .Issue.Comments}}
|
||||
{{ $createdStr:= TimeSince .Created $.Lang }}
|
||||
{{ $createdStr:= TimeSinceUnix .CreatedUnix $.Lang }}
|
||||
|
||||
<!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF, 5 = COMMENT_REF, 6 = PULL_REF, 7 = COMMENT_LABEL, 12 = START_TRACKING, 13 = STOP_TRACKING, 14 = ADD_TIME_MANUAL -->
|
||||
{{if eq .Type 0}}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
{{if .Issue.IsPull}}
|
||||
{{if .Issue.PullRequest.HasMerged}}
|
||||
{{ $mergedStr:= TimeSince .Issue.PullRequest.Merged $.Lang }}
|
||||
{{ $mergedStr:= TimeSinceUnix .Issue.PullRequest.MergedUnix $.Lang }}
|
||||
<a {{if gt .Issue.PullRequest.Merger.ID 0}}href="{{.Issue.PullRequest.Merger.HomeLink}}"{{end}}>{{.Issue.PullRequest.Merger.Name}}</a>
|
||||
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits .HeadTarget .BaseTarget $mergedStr | Str2html}}</span>
|
||||
{{else}}
|
||||
@@ -34,7 +34,7 @@
|
||||
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.title_desc" .NumCommits .HeadTarget .BaseTarget | Str2html}}</span>
|
||||
{{end}}
|
||||
{{else}}
|
||||
{{ $createdStr:= TimeSince .Issue.Created $.Lang }}
|
||||
{{ $createdStr:= TimeSinceUnix .Issue.CreatedUnix $.Lang }}
|
||||
<span class="time-desc">
|
||||
{{if gt .Issue.Poster.ID 0}}
|
||||
{{$.i18n.Tr "repo.issues.opened_by" $createdStr .Issue.Poster.HomeLink .Issue.Poster.Name | Safe}}
|
||||
|
@@ -18,7 +18,7 @@
|
||||
<li class="ui grid">
|
||||
<div class="ui four wide column meta">
|
||||
{{if .IsTag}}
|
||||
{{if .Created}}<span class="time">{{TimeSince .Created $.Lang}}</span>{{end}}
|
||||
{{if .CreatedUnix}}<span class="time">{{TimeSinceUnix .CreatedUnix $.Lang}}</span>{{end}}
|
||||
{{else}}
|
||||
{{if .IsDraft}}
|
||||
<span class="ui yellow label">{{$.i18n.Tr "repo.release.draft"}}</span>
|
||||
@@ -55,7 +55,7 @@
|
||||
<img class="img-10" src="{{.Publisher.RelAvatarLink}}">
|
||||
<a href="{{AppSubUrl}}/{{.Publisher.Name}}">{{.Publisher.Name}}</a>
|
||||
</span>
|
||||
{{if .Created}}<span class="time">{{TimeSince .Created $.Lang}}</span>{{end}}
|
||||
{{if .CreatedUnix}}<span class="time">{{TimeSinceUnix .CreatedUnix $.Lang}}</span>{{end}}
|
||||
<span class="ahead">{{$.i18n.Tr "repo.release.ahead" .NumCommitsBehind .Target | Str2html}}</span>
|
||||
</p>
|
||||
<div class="markdown desc">
|
||||
|
@@ -31,7 +31,7 @@
|
||||
{{.Fingerprint}}
|
||||
</div>
|
||||
<div class="activity meta">
|
||||
<i>{{$.i18n.Tr "settings.add_on"}} <span>{{DateFmtShort .Created}}</span> — <i class="octicon octicon-info"></i> {{if .HasUsed}}{{$.i18n.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="green"{{end}}>{{DateFmtShort .Updated}}</span>{{else}}{{$.i18n.Tr "settings.no_activity"}}{{end}}</i>
|
||||
<i>{{$.i18n.Tr "settings.add_on"}} <span>{{.CreatedUnix.FormatShort}}</span> — <i class="octicon octicon-info"></i> {{if .HasUsed}}{{$.i18n.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="green"{{end}}>{{.UpdatedUnix.FormatShort}}</span>{{else}}{{$.i18n.Tr "settings.no_activity"}}{{end}}</i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -76,7 +76,7 @@
|
||||
<input type="hidden" name="action" value="mirror-sync">
|
||||
<div class="inline field">
|
||||
<label>{{.i18n.Tr "repo.mirror_last_synced"}}</label>
|
||||
<span>{{.Mirror.Updated}}</span>
|
||||
<span>{{.Mirror.UpdatedUnix.AsTime}}</span>
|
||||
</div>
|
||||
<div class="field">
|
||||
<button class="ui blue button">{{$.i18n.Tr "repo.settings.sync_mirror"}}</button>
|
||||
|
@@ -16,7 +16,7 @@
|
||||
{{else if .Location}}
|
||||
<span class="octicon octicon-location"></span> {{.Location}}
|
||||
{{else}}
|
||||
<span class="octicon octicon-clock"></span> {{$.i18n.Tr "user.join_on"}} {{DateFmtShort .Created}}
|
||||
<span class="octicon octicon-clock"></span> {{$.i18n.Tr "user.join_on"}} {{.CreatedUnix.FormatShort}}
|
||||
{{end}}
|
||||
</div>
|
||||
</li>
|
||||
|
@@ -18,7 +18,7 @@
|
||||
<i class="octicon octicon-file-text"></i>
|
||||
<a href="{{$.RepoLink}}/wiki/{{.SubURL}}">{{.Name}}</a>
|
||||
</td>
|
||||
{{$timeSince := TimeSince .Updated $.Lang}}
|
||||
{{$timeSince := TimeSinceUnix .UpdatedUnix $.Lang}}
|
||||
<td class="text right grey">{{$.i18n.Tr "repo.wiki.last_updated" $timeSince | Safe}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
|
@@ -59,7 +59,7 @@
|
||||
|
||||
<div class="issue list">
|
||||
{{range .Issues}}
|
||||
{{ $timeStr:= TimeSince .Created $.Lang }}
|
||||
{{ $timeStr:= TimeSinceUnix .CreatedUnix $.Lang }}
|
||||
<li class="item">
|
||||
<div class="ui label">{{if not $.RepoID}}{{.Repo.FullName}}{{end}}#{{.Index}}</div>
|
||||
<a class="title has-emoji" href="{{AppSubUrl}}/{{.Repo.Owner.Name}}/{{.Repo.Name}}/issues/{{.Index}}">{{.Title}}</a>
|
||||
|
@@ -42,7 +42,7 @@
|
||||
</li>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<li><i class="octicon octicon-clock"></i> {{.i18n.Tr "user.join_on"}} {{DateFmtShort .Owner.Created}}</li>
|
||||
<li><i class="octicon octicon-clock"></i> {{.i18n.Tr "user.join_on"}} {{.Owner.CreatedUnix.FormatShort}}</li>
|
||||
<li>
|
||||
<i class="octicon octicon-person"></i>
|
||||
<a href="{{.Owner.HomeLink}}/followers">
|
||||
|
@@ -25,7 +25,7 @@
|
||||
<div class="content">
|
||||
<strong>{{.Name}}</strong>
|
||||
<div class="activity meta">
|
||||
<i>{{$.i18n.Tr "settings.add_on"}} <span>{{DateFmtShort .Created}}</span> — <i class="octicon octicon-info"></i> {{if .HasUsed}}{{$.i18n.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="green"{{end}}>{{DateFmtShort .Updated}}</span>{{else}}{{$.i18n.Tr "settings.no_activity"}}{{end}}</i>
|
||||
<i>{{$.i18n.Tr "settings.add_on"}} <span>{{.CreatedUnix.FormatShort}}</span> — <i class="octicon octicon-info"></i> {{if .HasUsed}}{{$.i18n.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="green"{{end}}>{{.UpdatedUnix.FormatShort}}</span>{{else}}{{$.i18n.Tr "settings.no_activity"}}{{end}}</i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -24,9 +24,9 @@
|
||||
<b>{{$.i18n.Tr "settings.subkeys"}}:</b> {{range .SubsKey}} {{.KeyID}} {{end}}
|
||||
</div>
|
||||
<div class="activity meta">
|
||||
<i>{{$.i18n.Tr "settings.add_on"}} <span>{{DateFmtShort .Added}}</span></i>
|
||||
<i>{{$.i18n.Tr "settings.add_on"}} <span>{{.AddedUnix.FormatShort}}</span></i>
|
||||
-
|
||||
<i>{{if not .Expired.IsZero }}{{$.i18n.Tr "settings.valid_until"}} <span>{{DateFmtShort .Expired}}</span>{{else}}{{$.i18n.Tr "settings.valid_forever"}}{{end}}</i>
|
||||
<i>{{if .ExpiredUnix}}{{$.i18n.Tr "settings.valid_until"}} <span>{{.ExpiredUnix.FormatShort}}</span>{{else}}{{$.i18n.Tr "settings.valid_forever"}}{{end}}</i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
{{.Fingerprint}}
|
||||
</div>
|
||||
<div class="activity meta">
|
||||
<i>{{$.i18n.Tr "settings.add_on"}} <span>{{DateFmtShort .Created}}</span> — <i class="octicon octicon-info"></i> {{if .HasUsed}}{{$.i18n.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="green"{{end}}>{{DateFmtShort .Updated}}</span>{{else}}{{$.i18n.Tr "settings.no_activity"}}{{end}}</i>
|
||||
<i>{{$.i18n.Tr "settings.add_on"}} <span>{{.CreatedUnix.FormatShort}}</span> — <i class="octicon octicon-info"></i> {{if .HasUsed}}{{$.i18n.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="green"{{end}}>{{.UpdatedUnix.FormatShort}}</span>{{else}}{{$.i18n.Tr "settings.no_activity"}}{{end}}</i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user