Fossil SCM
Added year=YYYY filter to /timeline, per request in [forum:/forumpost/7c923903ad45c8ea | forum post 7c923903ad45c8ea].
Commit
f8681a9c062042d86d53a5017ea5d90c05a0c8d2c0f29070d1915765226ecc99
Parent
939753d046ced49…
1 file changed
+45
+45
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1607,10 +1607,12 @@ | ||
| 1607 | 1607 | ** ym=YYYY-MM Show only events for the given year/month |
| 1608 | 1608 | ** yw=YYYY-WW Show only events for the given week of the given year |
| 1609 | 1609 | ** yw=YYYY-MM-DD Show events for the week that includes the given day |
| 1610 | 1610 | ** ymd=YYYY-MM-DD Show only events on the given day. The use "ymd=now" |
| 1611 | 1611 | ** to see all changes for the current week. |
| 1612 | +** year=YYYY Show only events on the given year. The use "year=0" | |
| 1613 | +** to see all changes for the current year. | |
| 1612 | 1614 | ** days=N Show events over the previous N days |
| 1613 | 1615 | ** datefmt=N Override the date format: 0=HH:MM, 1=HH:MM:SS, |
| 1614 | 1616 | ** 2=YYYY-MM-DD HH:MM:SS, 3=YYMMDD HH:MM, and 4 means "off". |
| 1615 | 1617 | ** bisect Show the check-ins that are in the current bisect |
| 1616 | 1618 | ** showid Show RIDs |
| @@ -1618,10 +1620,14 @@ | ||
| 1618 | 1620 | ** |
| 1619 | 1621 | ** p= and d= can appear individually or together. If either p= or d= |
| 1620 | 1622 | ** appear, then u=, y=, a=, and b= are ignored. |
| 1621 | 1623 | ** |
| 1622 | 1624 | ** If both a= and b= appear then both upper and lower bounds are honored. |
| 1625 | +** | |
| 1626 | +** When multiple time-related filters are used, e.g. ym, yw, and ymd, | |
| 1627 | +** which one(s) is/are applied is unspecified and may change between | |
| 1628 | +** fossil versions. | |
| 1623 | 1629 | ** |
| 1624 | 1630 | ** CHECKIN or TIMEORTAG can be a check-in hash prefix, or a tag, or the |
| 1625 | 1631 | ** name of a branch. |
| 1626 | 1632 | */ |
| 1627 | 1633 | void page_timeline(void){ |
| @@ -1650,10 +1656,11 @@ | ||
| 1650 | 1656 | const char *zUses = P("uf"); /* Only show check-ins hold this file */ |
| 1651 | 1657 | const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */ |
| 1652 | 1658 | const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */ |
| 1653 | 1659 | char *zYearWeekStart = 0; /* YYYY-MM-DD for start of YYYY-WW */ |
| 1654 | 1660 | const char *zDay = P("ymd"); /* Check-ins for the day YYYY-MM-DD */ |
| 1661 | + const char *zYear = P("year"); /* Events for the year YYYY */ | |
| 1655 | 1662 | const char *zNDays = P("days"); /* Show events over the previous N days */ |
| 1656 | 1663 | int nDays = 0; /* Numeric value for zNDays */ |
| 1657 | 1664 | const char *zChng = P("chng"); /* List of GLOBs for files that changed */ |
| 1658 | 1665 | int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */ |
| 1659 | 1666 | int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */ |
| @@ -2315,10 +2322,48 @@ | ||
| 2315 | 2322 | nDays = atoi(zNDays); |
| 2316 | 2323 | if( nDays<1 ) nDays = 1; |
| 2317 | 2324 | blob_append_sql(&cond, " AND event.mtime>=julianday('now','-%d days') ", |
| 2318 | 2325 | nDays); |
| 2319 | 2326 | nEntry = -1; |
| 2327 | + } | |
| 2328 | + else if( zYear && | |
| 2329 | + ((4==strlen(zYear) && atoi(zYear)>1900) | |
| 2330 | + || (1==strlen(zYear) && 0==atoi(zYear)))){ | |
| 2331 | + int year = atoi(zYear); | |
| 2332 | + char *zNext = 0; | |
| 2333 | + if(0==year){/*use current year*/ | |
| 2334 | + Stmt qy; | |
| 2335 | + db_prepare(&qy, "SELECT strftime('%%Y','now')"); | |
| 2336 | + db_step(&qy); | |
| 2337 | + year = db_column_int(&qy, 0); | |
| 2338 | + zYear = fossil_strdup(db_column_text(&qy, 0)); | |
| 2339 | + db_finalize(&qy); | |
| 2340 | + }else{ | |
| 2341 | + zNext = mprintf("%d", year+1); | |
| 2342 | + if( db_int(0, | |
| 2343 | + "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" | |
| 2344 | + " WHERE blob.rid=event.objid AND strftime('%%Y',mtime)=%Q %s)", | |
| 2345 | + zNext, blob_sql_text(&cond)) | |
| 2346 | + ){ | |
| 2347 | + zNewerButton = fossil_strdup(url_render(&url, "year", zNext, 0, 0)); | |
| 2348 | + zNewerButtonLabel = "Following year"; | |
| 2349 | + } | |
| 2350 | + fossil_free(zNext); | |
| 2351 | + } | |
| 2352 | + zNext = mprintf("%d", year-1); | |
| 2353 | + if( db_int(0, | |
| 2354 | + "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" | |
| 2355 | + " WHERE blob.rid=event.objid AND strftime('%%Y',mtime)=%Q %s)", | |
| 2356 | + zNext, blob_sql_text(&cond)) | |
| 2357 | + ){ | |
| 2358 | + zOlderButton = fossil_strdup(url_render(&url, "year", zNext, 0, 0)); | |
| 2359 | + zOlderButtonLabel = "Previous year"; | |
| 2360 | + } | |
| 2361 | + fossil_free(zNext); | |
| 2362 | + blob_append_sql(&cond, " AND %Q=strftime('%%Y',event.mtime) ", | |
| 2363 | + zYear); | |
| 2364 | + nEntry = -1; | |
| 2320 | 2365 | } |
| 2321 | 2366 | if( zTagSql ){ |
| 2322 | 2367 | db_multi_exec( |
| 2323 | 2368 | "CREATE TEMP TABLE selected_nodes(rid INTEGER PRIMARY KEY);" |
| 2324 | 2369 | "INSERT OR IGNORE INTO selected_nodes" |
| 2325 | 2370 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1607,10 +1607,12 @@ | |
| 1607 | ** ym=YYYY-MM Show only events for the given year/month |
| 1608 | ** yw=YYYY-WW Show only events for the given week of the given year |
| 1609 | ** yw=YYYY-MM-DD Show events for the week that includes the given day |
| 1610 | ** ymd=YYYY-MM-DD Show only events on the given day. The use "ymd=now" |
| 1611 | ** to see all changes for the current week. |
| 1612 | ** days=N Show events over the previous N days |
| 1613 | ** datefmt=N Override the date format: 0=HH:MM, 1=HH:MM:SS, |
| 1614 | ** 2=YYYY-MM-DD HH:MM:SS, 3=YYMMDD HH:MM, and 4 means "off". |
| 1615 | ** bisect Show the check-ins that are in the current bisect |
| 1616 | ** showid Show RIDs |
| @@ -1618,10 +1620,14 @@ | |
| 1618 | ** |
| 1619 | ** p= and d= can appear individually or together. If either p= or d= |
| 1620 | ** appear, then u=, y=, a=, and b= are ignored. |
| 1621 | ** |
| 1622 | ** If both a= and b= appear then both upper and lower bounds are honored. |
| 1623 | ** |
| 1624 | ** CHECKIN or TIMEORTAG can be a check-in hash prefix, or a tag, or the |
| 1625 | ** name of a branch. |
| 1626 | */ |
| 1627 | void page_timeline(void){ |
| @@ -1650,10 +1656,11 @@ | |
| 1650 | const char *zUses = P("uf"); /* Only show check-ins hold this file */ |
| 1651 | const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */ |
| 1652 | const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */ |
| 1653 | char *zYearWeekStart = 0; /* YYYY-MM-DD for start of YYYY-WW */ |
| 1654 | const char *zDay = P("ymd"); /* Check-ins for the day YYYY-MM-DD */ |
| 1655 | const char *zNDays = P("days"); /* Show events over the previous N days */ |
| 1656 | int nDays = 0; /* Numeric value for zNDays */ |
| 1657 | const char *zChng = P("chng"); /* List of GLOBs for files that changed */ |
| 1658 | int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */ |
| 1659 | int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */ |
| @@ -2315,10 +2322,48 @@ | |
| 2315 | nDays = atoi(zNDays); |
| 2316 | if( nDays<1 ) nDays = 1; |
| 2317 | blob_append_sql(&cond, " AND event.mtime>=julianday('now','-%d days') ", |
| 2318 | nDays); |
| 2319 | nEntry = -1; |
| 2320 | } |
| 2321 | if( zTagSql ){ |
| 2322 | db_multi_exec( |
| 2323 | "CREATE TEMP TABLE selected_nodes(rid INTEGER PRIMARY KEY);" |
| 2324 | "INSERT OR IGNORE INTO selected_nodes" |
| 2325 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1607,10 +1607,12 @@ | |
| 1607 | ** ym=YYYY-MM Show only events for the given year/month |
| 1608 | ** yw=YYYY-WW Show only events for the given week of the given year |
| 1609 | ** yw=YYYY-MM-DD Show events for the week that includes the given day |
| 1610 | ** ymd=YYYY-MM-DD Show only events on the given day. The use "ymd=now" |
| 1611 | ** to see all changes for the current week. |
| 1612 | ** year=YYYY Show only events on the given year. The use "year=0" |
| 1613 | ** to see all changes for the current year. |
| 1614 | ** days=N Show events over the previous N days |
| 1615 | ** datefmt=N Override the date format: 0=HH:MM, 1=HH:MM:SS, |
| 1616 | ** 2=YYYY-MM-DD HH:MM:SS, 3=YYMMDD HH:MM, and 4 means "off". |
| 1617 | ** bisect Show the check-ins that are in the current bisect |
| 1618 | ** showid Show RIDs |
| @@ -1618,10 +1620,14 @@ | |
| 1620 | ** |
| 1621 | ** p= and d= can appear individually or together. If either p= or d= |
| 1622 | ** appear, then u=, y=, a=, and b= are ignored. |
| 1623 | ** |
| 1624 | ** If both a= and b= appear then both upper and lower bounds are honored. |
| 1625 | ** |
| 1626 | ** When multiple time-related filters are used, e.g. ym, yw, and ymd, |
| 1627 | ** which one(s) is/are applied is unspecified and may change between |
| 1628 | ** fossil versions. |
| 1629 | ** |
| 1630 | ** CHECKIN or TIMEORTAG can be a check-in hash prefix, or a tag, or the |
| 1631 | ** name of a branch. |
| 1632 | */ |
| 1633 | void page_timeline(void){ |
| @@ -1650,10 +1656,11 @@ | |
| 1656 | const char *zUses = P("uf"); /* Only show check-ins hold this file */ |
| 1657 | const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */ |
| 1658 | const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */ |
| 1659 | char *zYearWeekStart = 0; /* YYYY-MM-DD for start of YYYY-WW */ |
| 1660 | const char *zDay = P("ymd"); /* Check-ins for the day YYYY-MM-DD */ |
| 1661 | const char *zYear = P("year"); /* Events for the year YYYY */ |
| 1662 | const char *zNDays = P("days"); /* Show events over the previous N days */ |
| 1663 | int nDays = 0; /* Numeric value for zNDays */ |
| 1664 | const char *zChng = P("chng"); /* List of GLOBs for files that changed */ |
| 1665 | int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */ |
| 1666 | int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */ |
| @@ -2315,10 +2322,48 @@ | |
| 2322 | nDays = atoi(zNDays); |
| 2323 | if( nDays<1 ) nDays = 1; |
| 2324 | blob_append_sql(&cond, " AND event.mtime>=julianday('now','-%d days') ", |
| 2325 | nDays); |
| 2326 | nEntry = -1; |
| 2327 | } |
| 2328 | else if( zYear && |
| 2329 | ((4==strlen(zYear) && atoi(zYear)>1900) |
| 2330 | || (1==strlen(zYear) && 0==atoi(zYear)))){ |
| 2331 | int year = atoi(zYear); |
| 2332 | char *zNext = 0; |
| 2333 | if(0==year){/*use current year*/ |
| 2334 | Stmt qy; |
| 2335 | db_prepare(&qy, "SELECT strftime('%%Y','now')"); |
| 2336 | db_step(&qy); |
| 2337 | year = db_column_int(&qy, 0); |
| 2338 | zYear = fossil_strdup(db_column_text(&qy, 0)); |
| 2339 | db_finalize(&qy); |
| 2340 | }else{ |
| 2341 | zNext = mprintf("%d", year+1); |
| 2342 | if( db_int(0, |
| 2343 | "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" |
| 2344 | " WHERE blob.rid=event.objid AND strftime('%%Y',mtime)=%Q %s)", |
| 2345 | zNext, blob_sql_text(&cond)) |
| 2346 | ){ |
| 2347 | zNewerButton = fossil_strdup(url_render(&url, "year", zNext, 0, 0)); |
| 2348 | zNewerButtonLabel = "Following year"; |
| 2349 | } |
| 2350 | fossil_free(zNext); |
| 2351 | } |
| 2352 | zNext = mprintf("%d", year-1); |
| 2353 | if( db_int(0, |
| 2354 | "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob" |
| 2355 | " WHERE blob.rid=event.objid AND strftime('%%Y',mtime)=%Q %s)", |
| 2356 | zNext, blob_sql_text(&cond)) |
| 2357 | ){ |
| 2358 | zOlderButton = fossil_strdup(url_render(&url, "year", zNext, 0, 0)); |
| 2359 | zOlderButtonLabel = "Previous year"; |
| 2360 | } |
| 2361 | fossil_free(zNext); |
| 2362 | blob_append_sql(&cond, " AND %Q=strftime('%%Y',event.mtime) ", |
| 2363 | zYear); |
| 2364 | nEntry = -1; |
| 2365 | } |
| 2366 | if( zTagSql ){ |
| 2367 | db_multi_exec( |
| 2368 | "CREATE TEMP TABLE selected_nodes(rid INTEGER PRIMARY KEY);" |
| 2369 | "INSERT OR IGNORE INTO selected_nodes" |
| 2370 |