Skip to content

Instantly share code, notes, and snippets.

@Attackmonkey
Attackmonkey / test-dIfferent-umbraco-queries
Created November 18, 2019 09:18
Testing Different Methods of Querying Content in Umbraco
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Umbraco.Web.Mvc;
using Umbraco.Web;
using Examine;
using UmbracoExamine;
@Attackmonkey
Attackmonkey / Get All Unpublished Content
Created July 16, 2019 07:27
Some queries for getting unpublished content from the Umbraco DB
--ALL UNPUBLISHED CONTENT (COMPLETELY UNPUBLISHED)
SELECT un.id, un.text FROM umbracoNode un
INNER JOIN cmsDocument cd ON un.id = cd.nodeId
WHERE cd.newest = 1 AND cd.published = 0
AND (SELECT COUNT(a.nodeId) FROM cmsDocument a WHERE a.nodeId = un.id AND a.published = 1 AND a.newest = 0) = 0
--ALL UNPUBLISHED CONTENT (COMPLETELY UNPUBLISHED), EXCLUDING DELETED ITEMS
SELECT un.id, un.text FROM umbracoNode un
INNER JOIN cmsDocument cd ON un.id = cd.nodeId
WHERE cd.newest = 1 AND cd.published = 0 AND un.path NOT LIKE '%-21,%'
@Attackmonkey
Attackmonkey / GiantMediaController.cs
Created May 31, 2019 15:00
How to get all large media items from Umbraco. You COULD use the Media Service, but this will be CONSIDERABLY faster. This example is just a surface controller and has no authentication. On a production environment you'd probably want to limit something like this to authenticated users.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Mvc;
using Umbraco.Core.Models;
using Umbraco.Web;
@Attackmonkey
Attackmonkey / Benchmark.js
Created July 13, 2017 10:37
Example JS to Call Test Methods of Benchmark Controller. Call these on a button click event!
//test each method, synchronously
var promises = [];
promises.push($.ajax({
url: '/umbraco/surface/benchmark/AllChildrenFromNode',
success: function (resp) {
var num = parseFloat(resp);
console.log('All By Direct Children: ' + num);
},
@Attackmonkey
Attackmonkey / BenchmarkController.cs
Last active July 13, 2017 10:28
Example of Umbraco Performance Test Controller - uses a generic timer method that all the other methods call. Pretty basic, but seems to work OK for quick and dirty benchmarks.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Umbraco.Web.Mvc;
using Umbraco.Web;
using Examine;
using UmbracoExamine;