summaryrefslogtreecommitdiff
path: root/gentoobrowse/console/fileimport.xml
blob: 19585cd7ac146014794dbb316eb8b2e5f82769cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?xml version="1.0"?>
<packageimport name="bugassociate" xmlns:xi="http://www.w3.org/2001/XInclude"
		xmlns:project2="http://project2.randomdan.homeip.net">
	<project2:sqlrows name="fileTypes" datasource="postgres">
		<sql>
			SELECT filetypeid, searchroot, searchspec
			FROM filetypes
			ORDER BY filetypeid DESC
		</sql>
	</project2:sqlrows>
	<project2:fsrows name="findCacheFiles" />

	<project2:sqlmerge name="files" datasource="postgres" targettable="files">
		<project2:iterate name="eachFileType" source="fileTypes">
			<project2:iterate name="eachCacheFile" source="findCacheFiles">
				<parameters>
					<root source="parent" name="searchroot" depth="1" />
					<spec source="parent" name="searchspec" depth="1" />
				</parameters>
				<project2:sqlmergeinsert name="insertFile">
					<parameters>
						<filename source="parent" attribute="relPath" depth="1" />
						<moddate source="parent" attribute="modifiedDate" depth="1"/>
						<filetypeid source="parent" name="filetypeid" depth="2" />
					</parameters>
				</project2:sqlmergeinsert>
			</project2:iterate>
		</project2:iterate>
		<columns>
			<column key="true">filename</column>
			<column>moddate</column>
			<column>filetypeid</column>
		</columns>
	</project2:sqlmerge>

	<project2:sqlrows name="outDatedFiles" datasource="postgres">
		<sql>
			SELECT f.fileid, ft.searchroot || f.filename AS filename, f.cachedat, f.moddate
			FROM files f, filetypes ft
			WHERE (f.cachedat IS NULL OR f.cachedat != f.moddate)
			AND f.filetypeid = ft.filetypeid
			AND ft.content
			ORDER BY f.fileid
		</sql>
	</project2:sqlrows>
	<project2:filerows name="readFileContent" newline="&#10;" encoding="utf-8" fieldSep="" quoteChar="" keepBlankRows="count" >
		<path source="parent" name="filename" depth="1" />
		<columns>
			<column>content</column>
		</columns>
	</project2:filerows>

	<project2:sqlmerge name="loadCacheContent" datasource="postgres" targettable="filecache"
			updatewhere="a.fileid IN (SELECT o.fileid FROM files o WHERE o.cachedat IS NULL OR o.cachedat != o.moddate)">
		<project2:iterate name="eachOutDatedFile" source="outDatedFiles">
			<project2:iterate name="eachFileContent" source="readFileContent">
				<project2:sqlmergeinsert name="insertFile">
					<parameters>
						<fileid source="parent" name="fileid" depth="2" />
						<line source="parent" attribute="rownum" depth="1" />
						<content source="parent" name="content" depth="1" />
					</parameters>
				</project2:sqlmergeinsert>
			</project2:iterate>
		</project2:iterate>
		<columns>
			<column key="true">fileid</column>
			<column key="true">line</column>
			<column>content</column>
		</columns>
	</project2:sqlmerge>

	<project2:sqltask name="setCachedTime" datasource="postgres">
		<sql>
			UPDATE files SET cachedat = moddate
			WHERE (cachedat != moddate OR cachedat IS NULL)
			AND filetypeid IN (SELECT filetypeid FROM filetypes WHERE content = TRUE)
		</sql>
	</project2:sqltask>
</packageimport>